Dear all,

Please copy and paste below query in query generator to get last document number that was posted for Sales quotation, order, return, delivery, invoice and credit memo.

SELECT T0.[CardCode],t0.[cardname],’Qutotation’, (select max(DocNum) from OQUT where cardcode = [%0] ) as Doc# FROM OQUT T0 WHERE T0.[CardCode] = [%0]   GROUP BY T0.[CardCode],t0.[cardname]

union all

SELECT T0.[CardCode],t0.[cardname],’SalesOrder’,(select max(DocNum) from ORDR where cardcode = [%0] ) as Doc# FROM ORDR T0 WHERE T0.[CardCode] = [%0]   GROUP BY T0.[CardCode],t0.[cardname]

union all

SELECT T0.[CardCode],t0.[cardname],’SalesReturn’,(select max(DocNum) from ORDN where cardcode = [%0] ) as Doc# FROM ORDN T0 WHERE T0.[CardCode] = [%0]   GROUP BY T0.[CardCode],t0.[cardname]

union all

SELECT T0.[Card

Code],t0.[cardname], ‘Delivery’,(select max(DocNum) from ODLN where cardcode = [%0] ) as Doc# FROM ODLN T0 WHERE T0.[CardCode] = [%0]   GROUP BY T0.[CardCode],t0.[cardname]

union all

SELECT T0.[CardCode],t0.[cardname], ‘Invoice’,(select max(DocNum) from OINV where cardcode = [%0] ) as Doc# FROM OINV T0 WHERE T0.[CardCode] = [%0]   GROUP BY T0.[CardCode],t0.[cardname]

union all

SELECT T0.[CardCode],t0.[cardname],’CreditMemo’,(select max(DocNum) from ORIN where cardcode = [%0] ) as Doc# FROM ORIN T0 WHERE T0.[CardCode] = [%0]   GROUP BY T0.[CardCode],t0.[cardname]

Hope helpful.

Thanks & Regards,

Nagarajan

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply