Morning all,
did a quick search but came up with nothing of what i think is a simple issue (simple because i can solve it in other languages just not SQL).
if you have a table with numerous a/p records i'm tring to pull the recordset back with 1 'V' (voucher) record and one displayed 'P' record (but need to cycle through and hit every 'P' record for my calculated field). Any suggestions?
SQL is as follows:
thanks in advance.
regards,
longhair
did a quick search but came up with nothing of what i think is a simple issue (simple because i can solve it in other languages just not SQL).
if you have a table with numerous a/p records i'm tring to pull the recordset back with 1 'V' (voucher) record and one displayed 'P' record (but need to cycle through and hit every 'P' record for my calculated field). Any suggestions?
SQL is as follows:
Code:
SELECT [vch-hdr].voucher, [vch-hdr].[inv-date], [vch-hdr].[inv-amt], [vch-hdr.inv-amt]-[aptrxp.amt-paid] AS Balance, aptrxp_2.type, aptrxp_1.type, aptrxp_1.[due-date], [vch-hdr.inv-amt]-[aptrxp.amt-paid] AS [Net Due]
FROM (([vch-hdr] LEFT JOIN aptrxp ON ([vch-hdr].[vend-num] = aptrxp.[vend-num]) AND ([vch-hdr].voucher = aptrxp.voucher)) LEFT JOIN aptrxp AS aptrxp_1 ON ([vch-hdr].voucher = aptrxp_1.voucher) AND ([vch-hdr].[vend-num] = aptrxp_1.[vend-num])) INNER JOIN aptrxp AS aptrxp_2 ON ([vch-hdr].voucher = aptrxp_2.[vend-num]) AND ([vch-hdr].[vend-num] = aptrxp_2.voucher)
WHERE ((([vch-hdr].[inv-date])>=[pQueryStart] And ([vch-hdr].[inv-date])<=[pQueryEnd]) AND ((aptrxp_2.type)="P") AND ((aptrxp_1.type)="V") AND (([vch-hdr].[vend-num])=[pQueryVend]))
ORDER BY [vch-hdr].voucher;
regards,
longhair