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 |
victorp
Starting Member
1 Post |
Posted - 2009-04-03 : 03:59:50
|
hello all,i have table having col 'code' and 'detail'------------code|detail. ------------4.....|victor4.....|185.....|macy.5.....|24how do i display the same info as----------------code|detail|age----------------4.....|victor|185.....|macy.|24please help with the query..regards |
|
CtrlAltPhreak
Starting Member
3 Posts |
Posted - 2009-04-03 : 04:51:25
|
Why do you not just have an age column in the table? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-04-03 : 05:06:04
|
quote: Originally posted by victorp hello all,i have table having col 'code' and 'detail'------------code|detail. ------------4.....|victor4.....|185.....|macy.5.....|24how do i display the same info as----------------code|detail|age----------------4.....|victor|185.....|macy.|24please help with the query..regards
Are the data coming from other sources or part of the table you have?MadhivananFailing to plan is Planning to fail |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-04-03 : 06:29:19
|
is this u want check this oncedeclare @tab table(code int,detail varchar(32))insert into @tab select 4,'victor'insert into @tab select 4,'18'insert into @tab select 5,'macy'insert into @tab select 5,'24'select code,max(case when code = 4 then detail when code = 5 then detail end) as name,min(case when code = 4 then detail when code = 5 then detail end) as agefrom @tabgroup by code |
|
|
|
|
|