Home All Groups Group Topic Archive Search About
Author
4 Nov 2005 4:44 PM
rodchar
hey all,
Given the table:
DeptName                    Status
IT        Updated
IT        Unchanged
IT        Unchanged
Finance        Updated
Finance        Unchanged


How do i answer this question in SQL syntax:
What is the total count for each status type?


The answer for the above scenario should be :
Unchanged       3
Updated       2   

thanks,
rodchar

Author
4 Nov 2005 4:48 PM
Aaron Bertrand [SQL Server MVP]
SELECT Status, COUNT(*)
FROM table_name_not_specified
GROUP BY Status




Show quote
"rodchar" <rodc***@discussions.microsoft.com> wrote in message
news:C5F677EC-CD46-402B-ACED-55435B2D7488@microsoft.com...
> hey all,
> Given the table:
> DeptName                 Status
> IT Updated
> IT Unchanged
> IT Unchanged
> Finance Updated
> Finance Unchanged
>
>
> How do i answer this question in SQL syntax:
> What is the total count for each status type?
>
>
> The answer for the above scenario should be :
> Unchanged    3
> Updated    2
>
> thanks,
> rodchar
Author
4 Nov 2005 5:10 PM
rodchar
Thank you.

Show quote
"Aaron Bertrand [SQL Server MVP]" wrote:

> SELECT Status, COUNT(*)
> FROM table_name_not_specified
> GROUP BY Status
>
>
>
>
> "rodchar" <rodc***@discussions.microsoft.com> wrote in message
> news:C5F677EC-CD46-402B-ACED-55435B2D7488@microsoft.com...
> > hey all,
> > Given the table:
> > DeptName                 Status
> > IT Updated
> > IT Unchanged
> > IT Unchanged
> > Finance Updated
> > Finance Unchanged
> >
> >
> > How do i answer this question in SQL syntax:
> > What is the total count for each status type?
> >
> >
> > The answer for the above scenario should be :
> > Unchanged    3
> > Updated    2
> >
> > thanks,
> > rodchar
>
>
>

AddThis Social Bookmark Button