Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.databases.ms-sqlserver    |    Notorious Rube Goldberg contraption    |    19,505 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 18,460 of 19,505    |
|    Lennart Jonsson to Phil Hunt    |
|    Re: SQL help    |
|    30 Sep 11 21:39:59    |
      XPost: microsoft.public.sqlserver.programming       From: erik.lennart.jonsson@gmail.com              On 2011-09-30 21:01, Phil Hunt wrote:       > Table2 ID Status       > 789 4       > 789 4       > 1374       >       > 1374       >       > 1374       >       > 1940 15       > 1940 15       > 1940 15       >       >       > I want to Select the above to output the followng       >       > 789 0       > 1374 0       > 1940 1 (because it has Status of 15)       >       >       > I have been staring at this so long, my head and eye hurts. Can someone help       > ?       >              I assume there is a good reason for the design of this table. Something       like:              select id, max(case when status = 15 then 1 else 0 end)       from t2       group by id              will do.                     /Lennart              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca