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@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! ;)

.



Relevant Pages

  • Re: COBOL stored procedure for DB2
    ... Regarding how you precompile the app, you must specify target mfcob to db2 prep, rather than target ibmcob. ... Have you also confirmed that, prior to executing the CALL statement, the host variables specified within the client app have the appropriate values? ... MODIFIES SQL DATA ... confirm the cob command used for creating the SP module. ...
    (comp.lang.cobol)
  • Re: COBOL stored procedure for DB2
    ... Have you also confirmed that, prior to executing the CALL statement, the ... The DB2 CREATE PROCEDURE statement. ... MODIFIES SQL DATA ... confirm the cob command used for creating the SP module. ...
    (comp.lang.cobol)
  • Re: Can I get Consultancy advice on SQL/Fox in the UK (South East)
    ... My problem is the two Sequel Server tables within one database with which I ... Don't ask me why but the SQL designers have NOT ... command that I can initiate with SQLCONNECT, ... > While you're in the View Designer, right-click and view the SQL code. ...
    (microsoft.public.fox.helpwanted)
  • Re: Optimistic Concurrency on UpdateCommand...
    ... client device, I update that column with a non-null datetime and then try to ... 1!!!If I copy and paste the command ... With the 4th column not allowing nulls, the optimistic concurrency code ... Can I have a nullable datetime column in my Sql ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Select - SQL vs. SUM
    ... If you have to use an earlier version of VFP earlier than 9, ... >> also force VFP to read from the buffer with a new clause in the SQL ... >> The SELECT command doesn't move the record pointer in the grid's record ... >>> I have a grid whose recordsource is a table named _payments. ...
    (microsoft.public.fox.programmer.exchange)