on 04-03-2010 1:40 PM
hi All,
I have a query which is repeating data in case multiple checks are used for payment;
SELECT DISTINCT T0.[DocDate], T1.[DueDate], T1.[CheckNum]as 'Cheque', T1.[BankCode] AS 'Bank Code' , T1.[Branch], T1.[AcctNum], T2.[AcctCode],T2.[Descrip], T2.[SumApplied], T0.[DocTotal] FROM OVPM T0 INNER JOIN VPM1 T1 ON T0.DocNum = T1.DocNum INNER JOIN VPM4 T2 ON T0.DocNum = T2.DocNum WHERE T0.[DocType] = 'A' and T0.[DocDate] >=[%0]
AND
T0.[DocDate] <=[%1] and T0.[DocNum] = [%3]
Let's say I selected doc type as accounts and at row level i selected 9 accounts. While on the payment means, i used 9 different checks for the payment. Now while viewing the data from this query, its repeating the data 81 times. How do i get to show only 9 accounts and 9 check number in the query? Please assist.
Thanks,
joseph
Hi Joseph,
Check your query result. For those 81 lines, one or more columns must have different values from each other. You need to omit those columns from your query.
Thanks,
Gordon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Closing the thread..
Thanks,
Joseph
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think your query is correct but for a few small corrections. The query below was test by me and it works. Check it out.
SELECT DISTINCT T0.DocDate, T1.DueDate, T1.CheckNum as 'Cheque', T1.BankCode AS 'Bank Code', T1.Branch,
T1.AcctNum, T2.AcctCode, T2.Descrip, T2.SumApplied, T0.DocTotal
FROM [dbo].[OVPM] T0 INNER JOIN [dbo].[VPM1] T1 ON T0.DocNum = T1.DocNum INNER JOIN [dbo].[VPM4] T2 ON T0.DocNum = T2.DocNum
WHERE T0.DocType = 'A' AND T0.DocDate BETWEEN '[%0]' AND '[%1]' AND T0.DocNum = '[%2]'
Regards
Suda
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi!
Try this
SELECT DISTINCT T0.DocDate, T1.DueDate, T1.CheckNum as 'Cheque', T1.BankCode AS 'Bank Code', T1.Branch,
T1.AcctNum, T2.AcctCode, T2.Descrip, T2.SumApplied, T0.DocTotal
FROM [dbo].[OVPM] T0 INNER JOIN [dbo].[VPM1] T1 ON T0.DocNum = T1.DocNum INNER JOIN [dbo].[VPM4] T2 ON
(T0.DocNum = T2.DocNum and T1.DocNum = T2.DocNum )
WHERE T0.DocType = 'A' AND T0.DocDate BETWEEN '[%0]' AND '[%1]' AND T0.DocNum = '[%2]'
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.