Skip to Content
0
Former Member
Mar 08, 2010 at 03:01 AM

last invoice & last payment in month

37 Views

good morning all the experts,

hallow all, I have a query like this:

SELECT

T0.[CardCode]as 'Customer Code', T0.[CardName]as 'Customer Name', T1.[PymntGroup]as 'T.O.P',

T2.[DocDate]as 'Invoice Date', T2.[DocNum] as 'Invoice Doc', T2.[DocDueDate] as 'Invoice Due Date',

T2.[DocTotal] as 'Tot Invoice', T3.[DocNum] as'Payment Doc', T3.[DocDueDate] as 'Payment Due date' ,

T3.[DocDate] as 'Payment Date', T3.[DocTotal] as 'Tot payment'

FROM

OCRD T0 INNER JOIN OCTG T1 ON T0.GroupNum = T1.GroupNum INNER JOIN

OINV T2 ON T0.CardCode = T2.CardCode INNER JOIN

ORCT T3 ON T2.ReceiptNum = T3.DocEntry

WHERE

T2.[DocDate] >=[%0]and

T2.[DocDate] <=[%1]and

T0.[CardName] =[%2]

if anyone can help me to display like this:

1. final invoice to customer A in one month

2. A customer shows the last payment in one month