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 |
|
bbarr
Starting Member
2 Posts |
Posted - 2010-10-22 : 09:38:06
|
| I have a report that is putting out data like this Account Number AttendingPhys Admitting Phys 101 John NULL101 NULL Peter1002 David NULL1002 NULL John Do you know how to combine the two rows to get: 101 John Peter1002 David JohnThanks! |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2010-10-22 : 10:22:29
|
| You can take a max on AttendingPhys and Admitting Physand group by Account NumberJimEveryday I learn something that somebody else already knew |
 |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-10-22 : 10:26:27
|
| Not sure is this you are looking for Select AccountNumber, Max(AttendingPhys), Max(Admitting Phys) from YourTAbleGroup by AccountNumberI am here to learn from Masters and help new bees in learning. |
 |
|
|
bbarr
Starting Member
2 Posts |
Posted - 2010-10-22 : 11:06:09
|
| I tried adding max to the code, but this did not fix the problem. I thought Max only worked on Numeric Records? |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2010-10-22 : 11:34:08
|
| DECLARE @Table TABLE (id int,col1 varchar(10),col2 varchar(10))INSERT INTO @TableSELECT '101','John', NULL UNION ALLSELECT '101',NULL,'Peter' UNION ALLSELECT '1002','David', NULL UNION ALLSELECT '1002',NULL,'John'SELECT id,max(col1),max(col2)from @tablegroup by idEveryday I learn something that somebody else already knew |
 |
|
|
|
|
|
|
|