|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Counting Help
I was hoping someone could assist me with a query that will allow me to count the number of records in a table where a field is equal to a certain status.
So in my table I have a field that is called Status. This field could have Dispatched, Deleted or QC in it. I need to count the number of records that are Dispatched and and count the number that are Deleted for a certain time period - Ideally I want to output this per month. So my results would be: Month - Dispatched Count - Deleted Count Thanks |
|
#2
|
||||
|
||||
|
You may need to try something like this, provided you're using an Access Database:
Code:
TRANSFORM Count([status]) SELECT [month], Count([status]) AS [Total Of Status] FROM Table3 GROUP BY [month] PIVOT [status]; Else If you're using MSSQL then you need to try something like this: Code:
SELECT Month, COUNT(CASE Status WHEN 1 THEN total END) AS Closed, COUNT(CASE Status WHEN 2 THEN total END) AS Sent FROM table GROUP BY Month Anyway, what you need to do is a Crosstab Query. You may need to check the help files for the application you're using. |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Counting Help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|