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 |
|
rubo81
Starting Member
2 Posts |
Posted - 2008-03-25 : 00:33:20
|
| Does anyone have any idea how to construct a select statement querying a temp table that contains the following data:Code | Jan-Apr | May-Aug | Sep-Dec----------------------------------------ABCD | 250.00 | NULL | NULLABCD | NULL | 889.56 | NULLABCD | NULL | NULL | 1233.67... that will merge the results as follows?Code | Jan-Apr | May-Aug | Sep-Dec----------------------------------------ABCD | 250.00 | 889.56 | 1233.67Your help would be greatly appreciated!Thanks. |
|
|
PeterNeo
Constraint Violating Yak Guru
357 Posts |
Posted - 2008-03-25 : 00:47:14
|
| try this,SELECT Code, MAX(Jan-Apr) as 'Jan-Apr', ...FROM tblGROUP BY Code |
 |
|
|
rubo81
Starting Member
2 Posts |
Posted - 2008-03-25 : 00:53:20
|
| Thanks SOOOOOOO much, Peter!! I knew there had to be a simple way, I was just not seeing it! |
 |
|
|
mahesh_bote
Constraint Violating Yak Guru
298 Posts |
Posted - 2008-03-25 : 02:03:18
|
| Select Code, SUM(Jan-Apr) As Jan-Apr, SUM(May-Aug) As May-Aug, SUM(Sep-Dec) As Sep-Dec From <Table> Group By CodeThanks,Mahesh |
 |
|
|
|
|
|