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 17,982 of 19,505    |
|    Lennart Jonsson to tshad    |
|    Re: Nulls to 0 in Pivot    |
|    26 Oct 10 22:07:52    |
      From: erik.lennart.jonsson@gmail.com              On 2010-10-26 21:37, tshad wrote:       > @sql comes up with the following:       >       > select * from #tfs       > PIVOT       > (       > SUM(Number)       > for retailer in([Sears], [CompUSA], [Lowes], [None], [K-Mart])       > ) as pvt       >              I would try something like:              select * from #tfs       PIVOT       (        SUM(coalesce(Number, 0))        for retailer in([Sears], [CompUSA], [Lowes], [None], [K-Mart])       ) as pvt              Not sure whether coalesce is coalesce or something else in sql-server       though. The function should return the leftmost argument that is not       null, in this case if Number is null -> 0.              Since I don't know the pivot function, there is a possibility that the       null you see origins from it, and if that is the case the solution above       wont work.              /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