Commands out of sync; you can't run this command now
(
Select h.INV_NO as 'Invoice No', date_format(h.INV_REC_DT,'%d.%m.%Y') as 'Invoice Rec Date', date_format(h.INV_POST_DT,'%d.%m.%Y') as 'Invoice Posting Date', date_format(h.INV_SEND_DT,'%d.%m.%Y') as 'Invoice Send Date' ,s.CUST_NAME as 'Customer Name' ,h.INV_AMT as 'Invoice Amount' ,s.SO_CURR as 'Currency' ,h.EXCH_RATE as 'Exchange Rate' ,p.PAYMENT_TERM_DAY as 'Payment Term', date_format(h.PYMT_DT_DUE,'%d.%m.%Y') as 'Payment Date (Due)', date_format(d.PYMT_DT_ACT,'%d.%m.%Y') as 'Payment Date (Actual)', if ((h.OUTSTD_AMT_TTL is null or h.OUTSTD_AMT_TTL <> 0),DateDiff(SYSDATE(),h.PYMT_DT_DUE),null) as 'Payment Date (Delay Days)', h.PYMT_DT_DELAY_REASON as 'Payment Delay Reason' ,d.PYMT_AMT_USD as 'Payment Amount (USD)' ,d.PYMT_AMT_EUR as 'Payment Amount (EUR)' ,d.PYMT_AMT_JPY as 'Payment Amount (JPY)' ,d.PYMT_AMT_IDR as 'Payment Amount (IDR)' ,d.OUTSTD_AMT_USD as 'Outstanding Amount (USD)' ,d.OUTSTD_AMT_EUR as 'Outstanding Amount (EUR)' ,d.OUTSTD_AMT_JPY as 'Outstanding Amount (JPY)' ,d.OUTSTD_AMT_IDR as 'Outstanding Amount (IDR)' ,h.OUTSTD_AMT_TTL as 'Outstanding Amount (Total)' ,h.CANCEL_STATUS as 'Cancel Status' ,h.CANCEL_REASON as 'Cancel Reason' ,h.PROBLEM as 'Problem' ,h.SOLUTION as 'Solution' ,h.COUNTERMEASURE as 'Countermeasure' ,d.seq as 'seq' from tb_r_inv_h h left join tb_r_inv_d d on (h.INV_NO = d.INV_NO) left join tb_r_gi_h gih on (h.inv_no = gih.inv_no) INNER JOIN tb_r_gi_d gid ON (gid.gi_NO = gih.gi_no) LEFT JOIN tb_r_so_h s ON (s.sof_no = gid.SOF_NO) left join tb_m_payment_term p on (h.PYMT_TERM = p.PAYMENT_TERM)
where gid.SOF_NO = '10-0003-J1' group by h.inv_no, d.seq
) union all (
Select h.INV_NO as 'Invoice No', date_format(h.INV_REC_DT,'%d.%m.%Y') as 'Invoice Rec Date', date_format(h.INV_POST_DT,'%d.%m.%Y') as 'Invoice Posting Date', date_format(h.INV_SEND_DT,'%d.%m.%Y') as 'Invoice Send Date' ,s.CUST_NAME as 'Customer Name' ,h.INV_AMT as 'Invoice Amount' ,s.SO_CURR as 'Currency' ,h.EXCH_RATE as 'Exchange Rate' ,p.PAYMENT_TERM_DAY as 'Payment Term', date_format(h.PYMT_DT_DUE,'%d.%m.%Y') as 'Payment Date (Due)', date_format(d.PYMT_DT_ACT,'%d.%m.%Y') as 'Payment Date (Actual)', if ((h.OUTSTD_AMT_TTL is null or h.OUTSTD_AMT_TTL <> 0),DateDiff(SYSDATE(),h.PYMT_DT_DUE),null) as 'Payment Date (Delay Days)', h.PYMT_DT_DELAY_REASON as 'Payment Delay Reason' ,d.PYMT_AMT_USD as 'Payment Amount (USD)' ,d.PYMT_AMT_EUR as 'Payment Amount (EUR)' ,d.PYMT_AMT_JPY as 'Payment Amount (JPY)' ,d.PYMT_AMT_IDR as 'Payment Amount (IDR)' ,d.OUTSTD_AMT_USD as 'Outstanding Amount (USD)' ,d.OUTSTD_AMT_EUR as 'Outstanding Amount (EUR)' ,d.OUTSTD_AMT_JPY as 'Outstanding Amount (JPY)' ,d.OUTSTD_AMT_IDR as 'Outstanding Amount (IDR)' ,h.OUTSTD_AMT_TTL as 'Outstanding Amount (Total)' ,h.CANCEL_STATUS as 'Cancel Status' ,h.CANCEL_REASON as 'Cancel Reason' ,h.PROBLEM as 'Problem' ,h.SOLUTION as 'Solution' ,h.COUNTERMEASURE as 'Countermeasure' ,d.seq as 'seq' from tb_r_inv_h h left join tb_r_inv_d d on (h.INV_NO = d.INV_NO) LEFT JOIN tb_r_so_h s ON (s.sof_no = h.SOF_NO) left join tb_m_payment_term p on (h.PYMT_TERM = p.PAYMENT_TERM)
where h.SOF_NO = '10-0003-J1' group by h.inv_no, d.seq
) order by 'Invoice No', 'seq', 'Payment Date (Actual)' asc limit 0,20
can some one tell me, why this query can't running in mysql query analyzer and show error Commands out of sync; you can't run this command now??