Avatar of John Ellis
John Ellis

asked on 

SQL: Counting the number of records


I'm surprised that this is harder than I thought it would be.  All I want it for T-SQL to tell me the number of records, for a date range.  The following is my query:

from HRI..SOP30200
where HRI..SOP30200.DOCDATE BETWEEN '2016-02-01' AND '2016-02-29' AND HRI..SOP30200.SOPTYPE = '3'

The query says "tell me the invoice number and its date, where the date range is 02/01/2016 through 02/29/2016.

I tried using select COUNT(), but all this did was give me over a thousand records with the number "1" in each record.

Wow!  I just want to know how many invoices are returned by this query--plain and simple.  How do I do that?


Microsoft SQL ServerMicrosoft SQL Server 2005Microsoft SQL Server 2008SQL

Avatar of undefined
Last Comment
Éric Moreau

8/22/2022 - Mon