Click here to Skip to main content
15,916,379 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table like

AccID	AccType 	Balance
1	Saving  	1-saving-bal
1	Current 	1-current-bal
2	Saving  	2-saving-bal
2	Current	        2-current-bal
3	Saving  	3-saving-bal
3	Current 	3-current-bal


I Want to retrieve the data like..

AccID	AccType 	Balance 	AccID2Balance
1	Saving  	1-saving-bal	2-saving-bal
1	Current 	1-current-bal	2-current-bal


How can i write query..

Please help..
Posted

1 solution

I got the Query..

SELECT t1.AccID,t1.AccType,t1.Balance,t2.Balance as AccID2Balance
FROM table_name t1 JOIN table_name t2 ON t1.Acctype=t2.AccType
WHERE t1.AccID=1 AND t2.AccID=2


Thank you... :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900