converting column values to column. [modified]
-
Table-A is having 4 columns. I want to select values from Table-A with values from Event columns as column names as shown in Table-B. I need a stored procedure for selecting it if its possible. TABLE-A ID.No--Name-----Event-----------Amount_Paid 1---- Terry---ReliefFund------100 1---- Terry---Donation--------200 2---- John----Festival--------100 2---- John----Donation--------300 TABLE-B ID.No---Name----ReliefFund------Donation--------Festival 1-------Terry---100-------------200-------------0 2-------John----0---------------300-------------100 Please help..., thanks
modified on Saturday, December 11, 2010 12:45 AM
-
Table-A is having 4 columns. I want to select values from Table-A with values from Event columns as column names as shown in Table-B. I need a stored procedure for selecting it if its possible. TABLE-A ID.No--Name-----Event-----------Amount_Paid 1---- Terry---ReliefFund------100 1---- Terry---Donation--------200 2---- John----Festival--------100 2---- John----Donation--------300 TABLE-B ID.No---Name----ReliefFund------Donation--------Festival 1-------Terry---100-------------200-------------0 2-------John----0---------------300-------------100 Please help..., thanks
modified on Saturday, December 11, 2010 12:45 AM
-
Table-A is having 4 columns. I want to select values from Table-A with values from Event columns as column names as shown in Table-B. I need a stored procedure for selecting it if its possible. TABLE-A ID.No--Name-----Event-----------Amount_Paid 1---- Terry---ReliefFund------100 1---- Terry---Donation--------200 2---- John----Festival--------100 2---- John----Donation--------300 TABLE-B ID.No---Name----ReliefFund------Donation--------Festival 1-------Terry---100-------------200-------------0 2-------John----0---------------300-------------100 Please help..., thanks
modified on Saturday, December 11, 2010 12:45 AM
Use PIVOT and UNPIVOT[^]
thatraja |Chennai|India|
Brainbench certifications
Univotes are like kid's kisses don't reject it :-)
Do what you want quickly because the Doomsday on 2012 :-)
My childhood story -
Table-A is having 4 columns. I want to select values from Table-A with values from Event columns as column names as shown in Table-B. I need a stored procedure for selecting it if its possible. TABLE-A ID.No--Name-----Event-----------Amount_Paid 1---- Terry---ReliefFund------100 1---- Terry---Donation--------200 2---- John----Festival--------100 2---- John----Donation--------300 TABLE-B ID.No---Name----ReliefFund------Donation--------Festival 1-------Terry---100-------------200-------------0 2-------John----0---------------300-------------100 Please help..., thanks
modified on Saturday, December 11, 2010 12:45 AM
SELECT * FROM mytable AS A
PIVOT (
SUM(AMOUNT)
FOR MEVENT IN([ReliefFund], [Donation], [Festival])
) AS M -
Table-A is having 4 columns. I want to select values from Table-A with values from Event columns as column names as shown in Table-B. I need a stored procedure for selecting it if its possible. TABLE-A ID.No--Name-----Event-----------Amount_Paid 1---- Terry---ReliefFund------100 1---- Terry---Donation--------200 2---- John----Festival--------100 2---- John----Donation--------300 TABLE-B ID.No---Name----ReliefFund------Donation--------Festival 1-------Terry---100-------------200-------------0 2-------John----0---------------300-------------100 Please help..., thanks
modified on Saturday, December 11, 2010 12:45 AM
-
Table-A is having 4 columns. I want to select values from Table-A with values from Event columns as column names as shown in Table-B. I need a stored procedure for selecting it if its possible. TABLE-A ID.No--Name-----Event-----------Amount_Paid 1---- Terry---ReliefFund------100 1---- Terry---Donation--------200 2---- John----Festival--------100 2---- John----Donation--------300 TABLE-B ID.No---Name----ReliefFund------Donation--------Festival 1-------Terry---100-------------200-------------0 2-------John----0---------------300-------------100 Please help..., thanks
modified on Saturday, December 11, 2010 12:45 AM