View Single Post

   
  #5 (permalink)  
Old 03-01-2008, 03:49 PM
Dan Guzman
 
Posts: n/a
Default Re: Query - select common data from one column and display in several columns

> 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@gmail.com> wrote in message
news:c67bdcc0-abe2-4f25-a4e8-bcd5151830ff@60g2000hsy.googlegroups.com...
> On Feb 28, 11:56 am, Mark <markc...@hotmail.com> 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!


Reply With Quote