Re: Query - select common data from one column and display in several columns
- From: "Dan Guzman" <guzmanda@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 28 Feb 2008 12:18:00 GMT
I didn't know the command "case when filed=value then X else Y end"
Note that a SQL CASE is an expression rather than a command (as in some other languages). You can use it where expressions are allowed in SQL.
--
Hope this helps.
Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/
"rui dias" <rldias@xxxxxxxxx> wrote in message news:c67bdcc0-abe2-4f25-a4e8-bcd5151830ff@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Feb 28, 11:56 am, Mark <markc...@xxxxxxxxxxx> wrote:select Name,
sum(case when note=5 then 1 else 0 end) as note5,
sum(case when note=4 then 1 else 0 end) as note4
from mytable
group by Name
Hello Mark,
Thanks a lot for your answer.
It is really nice!
I didn't know the command "case when filed=value then X else Y end"
Really nice! ;)
.
- References:
- Prev by Date: Re: Query - select common data from one column and display in several columns
- Next by Date: Re: Track changes made to SQL Server
- Previous by thread: Re: Query - select common data from one column and display in several columns
- Next by thread: Re: Query - select common data from one column and display in several columns
- Index(es):
Relevant Pages
|