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 HussainPosted Aug 12, 2013, 4:04 AM
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
selva kumarPosted Aug 12, 2013, 4:30 AM
divyaPosted Aug 12, 2013, 4:02 AM
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