on 08-16-2016 4:15 PM
Dear All,
Please help me to find out the Repeating customers in a month with customer name and doc total.And from this report i shall identify how many customers repeatedly came .Please help me with a query to find the same.
Regards,
Sri
Hi Sri,
Please give this a try:
/* select * from OINV x */
DECLARE @M AS DATETIME = /* x.DocDate */ '[%0]'
SELECT c.CardCode
,c.CardName
,ISNULL(COUNT(DISTINCT h.DocNum),0) AS NrOfInvoices
FROM OCRD c
LEFT OUTER JOIN OINV h ON c.CardCode = h.CardCode
WHERE MONTH(h.DocDate) = MONTH(@M)
AND YEAR(h.DocDate) = YEAR(@M)
GROUP BY c.CardCode
,c.CardName
HAVING ISNULL(COUNT(DISTINCT h.DocNum),0) > 1
Regards,
Johan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
6 | |
6 | |
4 | |
3 | |
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.