I want to display the top five Total values from these tables in single column By using sql joins...i am new to sql server can anyone help me out...
Here is my sample table....
table1
| Name | Group | Total |
| aaa | Biologymaths | 1100 |
| bbb | Biologymaths | 1150 |
| ccc | Biologymaths | 1089 |
| Name | Group | Total |
| ddd | ComputerBiology | 1010 |
| eee | ComputerBiology | 1101 |
| fff | ComputerBiology | 1128 |
Table3
| Name | Group | Total |
| ggg | Arts | 1078 |
| hhh | Arts | 1100 |
| iii | Arts | 1059 |


Iftikar HussainRank #423 · 5.9K reputationPosted Aug 12, 2013, 12:04 AM EDT
Try like this
SELECT TOP 5 Name,Group,Total FROM
(
SELECT Name,Group,Total FROM table1
UNION ALL
SELECT Name,Group,Total FROM table2
UNION ALL
SELECT Name,Group,Total FROM table3
) As Data
ORDER BY Total desc
Regards,
Iftikar
divya146 reputationPosted Aug 12, 2013, 12:02 AM EDT
Hai selva kumar,
You can use Unions to do this. First union command to mix all tables ,then use top 5 to select top five Total values.Hope This will Help you .
Regards
Divya
selva kumarRank #2,987 · 483 reputationPosted Aug 12, 2013, 12:30 AM EDT