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 |
|
Inno
Starting Member
33 Posts |
Posted - 2006-06-28 : 04:03:02
|
| Say I have a table with the columns (and example data):CustomerNo, ContactNo, ActivityNonull, null, 1100, null, 1null, 666, 1null, null, 2200, null, 2null, 777, 2From this I would like to get the result:CustomerNo, ContactNo, ActivityNo100, 666, 1200, 777, 2How do I solve this. Im getting grey hair here... |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-06-28 : 04:11:11
|
| You should not allow null values in customerNoTry thisSelect max(CustomerNo) as CustomerNo, max(ContactNo) as ContactNo,ActivityNo from yourtablegroup by ActivityNoMadhivananFailing to plan is Planning to fail |
 |
|
|
Inno
Starting Member
33 Posts |
Posted - 2006-06-28 : 04:30:37
|
| Awsome. How do I create a temporary table with this data so I can use it in another transaction? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-06-28 : 04:36:50
|
| Create table #t(....) --same structure as original tableInsert into #tSelect max(CustomerNo) as CustomerNo, max(ContactNo) as ContactNo,ActivityNo from yourTablegroup by ActivityNoSelect * from #tMadhivananFailing to plan is Planning to fail |
 |
|
|
Inno
Starting Member
33 Posts |
Posted - 2006-06-28 : 04:54:39
|
| You are the man madhivanan! Thanx. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|
|