How to Count lines

I am trying to count the number of lines and i am using Count(OrderHed.DocOrderAmt). The goal is to count the number of lines for a certain dollar amount spent. I have the dollar amount worked out, but the counting is telling me there is an incorrect syntax near ‘OrderHed’

I have added the field Company and it is group by using that field and the counting seems to work.

The SQL query looks like

select 
	[OrderHed].[Company] as [OrderHed_Company],
	(count( OrderHed.DocOrderAmt )) as [Calculated_CountOrderAmt]
from Erp.OrderHed as OrderHed
group by [OrderHed].[Company]
1 Like

If your query uses an aggregate calculation(SUM, COUNT, MAX,etc…) The other fields must all be group by.

2 Likes