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 |
thanksfor help
Posting Yak Master
106 Posts |
Posted - 2006-09-22 : 12:55:26
|
Hi,I have a table in following structureitem_no level item_name1234 1 ABCD1234 2 xyz1234 3 pqrs8907 3 jack8907 2 jim8907 1 paul2378 2 julie2378 1 nancy2378 3 emilySelect on the above table shld returnitem_no l1 l1_name l2 l2_name l3 l3_name 1234 1 ABCD 2 XYZ 3 pqrs8907 1 Paul 2 jim 3 jack2378 1 nancy 2 julie 3 emilyAny help is very much appreciated. |
|
X002548
Not Just a Number
15586 Posts |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-09-22 : 13:04:25
|
select item_no, 1, t1.item_name, 2, t2.item_name, 3, t3.item_name, 4, t4.item_namefrom (select distinct item_no from tbl) tjoin tbl t1on t.item_no = t1.item_no and t1.level = 1left join tbl t2on t.item_no = t2.item_no and t2.level = 2left join tbl t3on t.item_no = t3.item_no and t3.level = 3left join tbl t4on t.item_no = t4.item_no and t4.level = 4==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
thanksfor help
Posting Yak Master
106 Posts |
Posted - 2006-09-22 : 14:48:50
|
Thanks it worked |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|