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 |
|
kemalemin
Starting Member
1 Post |
Posted - 2005-11-22 : 17:48:02
|
| Hi, The example of what I'm trying to do is below; (obviously it doesn't work but you get the idea)SELECT SUM(clicks) AS X, SUM(impressions) AS Y WHERE TYPE=0, SELECT SUM(clicks) AS X1, SUM(impressions) AS Y1 WHERE TYPE=1If I use "groupby type", then two rows are returned. I want the query return only single row such as; x | y | x1 | y1---------------- 19|20 | 32 | 30any help would be appreciated.Regards,Kemal |
|
|
rfrancisco
Yak Posting Veteran
95 Posts |
Posted - 2005-11-22 : 18:23:16
|
| Hi Kemal,Try this:SELECT SUM(CASE WHEN TYPE = 0 THEN CLICKS ELSE 0 END) AS X, SUM(CASE WHEN TYPE = 0 THEN IMPRESSIONS ELSE 0 END) AS Y, SUM(CASE WHEN TYPE = 1 THEN CLICKS ELSE 0 END) AS X1, SUM(CASE WHEN TYPE = 1 THEN IMPRESSIONS ELSE 0 END) AS Y1FROM YourTableHope this helps.http://www.sql-server-helper.com |
 |
|
|
|
|
|