|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Need Help on COUNT SQL Query
Here is what I am trying to do.
List all ProjectNumbers between two dates with a count of how many are there. There are multiple ProjectNumbers between these dates. What I need is to get a count and display a single ProjectNumber and its Count Example Code:
Proj# Count P123 12 P234 23 P345 1 Here is a query I have been working on any help would be great. Code:
SELECT DISTINCT ( P1.ProjectNumber), (SELECT COUNT(*) FROM PhotoLogIn AS P2 WHERE P2.ProjectNumber = P1.ProjectNumber) AS RollCount FROM PhotoLogIn AS P1 WHERE (((P1.DateTaken) Between #1/1/2003# And #8/29/2003#)) ORDER BY P1.ProjectNumber;
__________________
George - www.ipdg3.com Helping Developers and Programmers Find Resources Forums - Contests - Tutorials - Source Code ORB - Wireless Site - Online Gear |
|
#2
|
|||
|
|||
|
Code:
select ProjectNumber, count(*) as RollCount from PhotoLogIn where DateTaken Between #1/1/2003# And #8/29/2003# group by ProjectNumber ORDER BY ProjectNumber |
|
#3
|
|||
|
|||
|
swampBoogie Thanks
After I made the post I realized that I messed up the COUNT. Also you do not use DISTINCT with COUNT. I must say thank you so much this is a huge help. |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Need Help on COUNT SQL Query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|