mohanaraj
SSC-Addicted
Points: 406
More actions
April 10, 2010 at 4:44 am
#99129
Dear all,
How can i get the following result using below details ?
The table have the data like below
INPUT:(Table's data)
id curre rate
1 USD 4.2
2 INR 5.6
3 usd 5.2
I want the result.
RESULT:
Id USD IND
1 4.2 0
2 0 5.6
3 5.2 0
please help me....
Regards
Mohanaraj.
Mahesh Bote
SSCrazy Eights
Points: 9107
April 10, 2010 at 5:03 am
#1149544
[font="Verdana"]
try this
Selectid
,USD = (Case When Curre = 'usd' Then Rate Else 0 End)
,INR = (Case When Curre = 'inr' Then Rate Else 0 End)
FromTable
--Mahesh
[/font]
MH-09-AM-8694
Arshad Kalam
SSC Enthusiast
Points: 109
April 12, 2010 at 6:02 am
#1149950
You can also use PIVOT operator. Here is the example
select id, USD = ISNull([USD], 0), IND = IsNull([IND], 0)
From
(
Select id, Curr, rate
from Table
) AS Tb
Pivot
Sum(Rate)
For Curr in ([USD], [IND])
) As Pv
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply