Click here to Skip to main content
15,909,051 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sql query for read count between two values.

I am using bellow query. but it can retrieving only individual dates count.
SQL
select EA_STATION_ID, EA_MONTH,EA_DATE,count(EA_DATE)
  from data
  group by EA_STATION_ID, EA_DATE,EA_MONTH
  having  EA_DATE between 00 and 10
Posted
Updated 2-Jun-13 23:07pm
v2
Comments
KarthickInfosys 3-Jun-13 5:07am    
here you mention (having EA_DATE between 00 and 10) actually what is condition date
like 31/05/2013 and 02/06/2013
Maciej Los 3-Jun-13 5:12am    
We need example data and expected output to help you find a solution...
Use "Improve question" widget.

1 solution

SQL
select EA_STATION_ID, EA_MONTH,EA_DATE,count(EA_DATE)
from data
WHERE EA_DATE between @DATE AND @DATE
group by EA_STATION_ID, EA_DATE,EA_MONTH
having EA_DATE between 00 and 10


Use the where clause should be ok i think. try and see.
 
Share this answer
 
Comments
Maciej Los 3-Jun-13 5:10am    
Using Having clause without aggregate function raises an error ;(
HAVING COUNT(EA_DATE) <= 10 - it should be OK.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900