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 |
naz@ukchoice
Starting Member
3 Posts |
Posted - 2006-03-13 : 09:51:48
|
Hi All,I m having some problems with query, dont know how to get this result in sql server 2000.I have tables show below:table 1 ManufacturerManfID, ManfDesc1 , Nokia2 , Motorola==============table 2 : HandsetHandsetId, ModelDesc , ManfId1 , 6230i , 12 , V3 , 2=================table 3 : FeaturesfeatureId , FeatureDesc1 , Size2 , Talk time3 , Bluetooth=============table 4 : handsetFeaturesHandsetId, featureId, FeatureValue1 , 1 , 64 x 241 , 2 , 5 Hours1 , 3 , Yes2 , 1 , 50 x 252 , 3 , YesI want to get results like thisHandset Name , size , Talk time , BluetoothNokia 6230i , 64 x 24 , 5 Hours , YesMotorola V3 , 50 x 25 , N/A , yesAny query pleaseThanx |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
naz@ukchoice
Starting Member
3 Posts |
Posted - 2006-03-13 : 10:35:00
|
Thanx for reply Madhivanan Excellent Article. This is the thing I was looking for. |
|
|
naz@ukchoice
Starting Member
3 Posts |
Posted - 2006-03-13 : 12:31:40
|
Hi All,Its the sime kind of situation again but i would like to get resutls in select statement (tabular Format) and each value have its own column header likeshown below:-Handset Name Size talktime Nokia 6230i 64 x 24 5 HoursMotorola V3 50 x 25 N/ACheers |
|
|
sweta.jha
Starting Member
2 Posts |
Posted - 2006-03-29 : 01:12:37
|
You need to manipulate the query below lil more in order to get data in desired format.select A.HandsetName,A.Size,A.TalkTime,A.Bluetooth from(select ManfDesc + ' ' + ModelDesc as HandsetName,(case when HF.FeatureId = F.FeatureId and F.FeatureDesc = 'Size' then HF.FeatureValue else null end) as Size,(case when HF.FeatureId = F.FeatureId and F.FeatureDesc = 'TalkTime' then HF.FeatureValue else null end)as TalkTime,(case when HF.FeatureId = F.FeatureId and F.FeatureDesc = 'Bluetooth' then HF.FeatureValue else null end) as Bluetoothfrom Manufacturer M inner join Handset Hon M.ManfId = H.ManfIdInner JoinHandsetFeatures HFon HF.HandsetId = H.HandsetIdInner JoinFeatures Fon HF.FeatureId = F.FeatureId)A |
|
|
sweta.jha
Starting Member
2 Posts |
Posted - 2006-03-29 : 01:59:38
|
A better one over the last replyselect ManfDesc + ' ' + ModelDesc as HandsetName,Max(case when HF.FeatureId = F.FeatureId and F.FeatureDesc = 'Size' then HF.FeatureValue else null end) as Size,isnull(Max(case when HF.FeatureId = F.FeatureId and F.FeatureDesc = 'TalkTime' then HF.FeatureValue else null end),'N/A')as TalkTime,Max(case when HF.FeatureId = F.FeatureId and F.FeatureDesc = 'Bluetooth' then HF.FeatureValue else null end) as Bluetoothfrom Manufacturer M inner join Handset Hon M.ManfId = H.ManfIdInner JoinHandsetFeatures HFon HF.HandsetId = H.HandsetIdInner JoinFeatures Fon HF.FeatureId = F.FeatureIdgroup by ManfDesc + ' ' + ModelDesc |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-03-29 : 02:19:28
|
quote: Originally posted by naz@ukchoice Hi All,Its the sime kind of situation again but i would like to get resutls in select statement (tabular Format) and each value have its own column header likeshown below:-Handset Name Size talktime Nokia 6230i 64 x 24 5 HoursMotorola V3 50 x 25 N/ACheers
Why do you want to do this in T-SQL ? It can be done easily in your front end application KHChoice is an illusion, created between those with power, and those without.Concordantly, while your first question may be the most pertinent, you may or may not realize it is also the most irrelevant |
|
|
|
|
|
|
|