cancel
Showing results for 
Search instead for 
Did you mean: 

Invoice Count

Former Member
0 Kudos

Hi Gurus,

i need a query to show me a supplier who has invoiced me 5 or less time in a month

Regards

Francis

Accepted Solutions (0)

Answers (3)

Answers (3)

KennedyT21
Active Contributor
0 Kudos

what do you mean.

what is the requirement, you need the balance of the supplier also?

Rgds

Former Member
0 Kudos

yes

97yesyes
KennedyT21
Active Contributor
0 Kudos

try this

SELECT T0.[CardCode],

       T0.[CardName],

       COUNT(T0.docnum) as COUNT , Balance =( SELECT Balance  FROM ocrd WHERE cardcode=t0.cardcode)

FROM   OPCH T0

WHERE  T0.[DocDate] BETWEEN [%0] AND [%1]

AND CANCELED = 'N' AND t0.docstatus='O'

GROUP BY

       T0.[CardCode],

       T0.[CardName]

HAVING COUNT(docnum) <= 5

kothandaraman_nagarajan
Active Contributor
0 Kudos

Hi,

Please try this:

SELECT T0.[CardCode],

       T0.[CardName],

       COUNT(T0.docnum) as Count

FROM   OPCH T0

WHERE  T0.[DocDate] BETWEEN [%0] AND [%1]

GROUP BY

       T0.[CardCode],

       T0.[CardName]

HAVING COUNT(docnum) <= '5'

Thanks

frank_wang6
Active Contributor
0 Kudos

SELECT T0.[CardCode],

       T0.[CardName],

       COUNT(T0.docnum) as Count

FROM   OPCH T0

WHERE  T0.[DocDate] BETWEEN [%0] AND [%1]

AND CANCELED = 'N'

GROUP BY

       T0.[CardCode],

       T0.[CardName]

HAVING COUNT(docnum) <= 5

I think removing canceled document will be better.

Frank

Former Member
0 Kudos

hi frank,

This shows me greater than 5 but i changed can it show the balance

27
Former Member
0 Kudos

hi frank,

This shows me greater than 5 but i changed can it show the balance

28
Former Member
0 Kudos

hi Nagarajan,

This shows me greater than 5 but i changed can it show the balance

31
KennedyT21
Active Contributor
0 Kudos

Try this

SELECT T0.[CardCode],

       T0.[CardName],

       COUNT(docnum)

FROM   OPCH T0

WHERE  T0.[DocDate] BETWEEN [%0] AND [%1]

GROUP BY

       T0.[CardCode],

       T0.[CardName]

HAVING COUNT(docnum) <= '5'