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 |
|
Gudiya
Starting Member
14 Posts |
Posted - 2012-08-06 : 20:58:19
|
| I have to the following case statement that calculates count and sum respectively:if colA='e' or (cola='f' and colb<>0) and date=2012then set xy=1else set xy= oif colA='e' or (cola='f' and colb<>0) and date=2012then sum yelse ohere, I am joining 3 tables. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
ashishashish
Constraint Violating Yak Guru
408 Posts |
Posted - 2012-08-07 : 03:38:26
|
Can you please elobrate your requirement more clearly..?quote: Originally posted by Gudiya I have to the following case statement that calculates count and sum respectively:if colA='e' or (cola='f' and colb<>0) and date=2012then set xy=1else set xy= oif colA='e' or (cola='f' and colb<>0) and date=2012then sum yelse ohere, I am joining 3 tables.
------------------------------------------------The answer is always no till than you don't ask. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-07 : 09:51:27
|
just translate it to case ...when..case when colA='e' or (cola='f' and colb<>0) and date=2012then 1else 0end as xy,case when colA='e' or (cola='f' and colb<>0) and date=2012then sum(y)else 0end as othercol.. ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|