We help IT Professionals succeed at work.
Get Started

SQL:  Counting the number of records

374 Views
Last Modified: 2016-03-09
Hello:

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:

select HRI..SOP30200.SOPNUMBE, HRI..SOP30200.DOCDATE
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?

Thanks!

John
Comment
Watch Question
Senior .Net Consultant
CERTIFIED EXPERT
Top Expert 2016
Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE