Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-23 : 01:19:45
|
quote: Originally posted by maya_zakry hello, can someone fix my multiple case statement.. SELECT col1, col2 from tblOneCASE WHEN (substring(d.StorageStatus,1,1)='H') THEN Sum(d.HoldQty)WHEN (substring(d.StorageStatus,1,1)='Q') THEN Sum(d.QCQty)ELSE sum(ISNULL(d.OriginQty,0))-sum(ISNULL(d.HoldQty,0))- sum(ISNULL (d.QCQty,0))- sum(ISNULL(d.BookQty,0))- sum(ISNULL(p.PickQty,0)) AS BalQty ENDAS BalQtyWHERE blablahis this multiple case allowed?
NO!But if you are trying to sum up different columns depening on some status column, try thisselect col1, col2, sum(case when d.storagestatus like 'h%' then isnull(d.holdqty, 0) when d.storagestatus like 'q%' then isnull(d.qcqty, 0) else isnull(d.originqty, 0) - isnull(d.holdqty, 0) - isnull (d.qcqty, 0) - isnull(d.bookqty, 0) - isnull(p.pickqty, 0) end) as qtyfrom tblonegroup by col1, col2order by col1, col2 Peter LarssonHelsingborg, Sweden |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-23 : 01:32:36
|
huh  KH |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-23 : 01:43:14
|
| Maya deleted the topic the second before I posted my suggestion.And I thought the question and suggestion was valuable enough for more users to learn from.Peter LarssonHelsingborg, Sweden |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-01-23 : 02:52:13
|
Of all the posts to pad in all the forums in all the world, you have to pick on Maya_Zakry? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-23 : 03:02:39
|
Even if he walked into SQLTeam bar? The question still remain, why he wold not let other people benefit from the question and answer, as he has himself been helped numerous times before?Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|
|