Below is my table data
Mat Phy Chem
20 30 40
25 35 35
45 30 30
45 40 35
I want to retrieve top 3 max rows of all the three columns in a single row.
O/P
Mat Phy Chem
45 40 40
25 35 35
20 30 30
I have used below query but was unsuccessful, please help...
Select distinct top 3 max(mat) from studata group by mat order by max(mat) desc
Union all
Select distinct top 3 max(phy) from studata group by phy order by max(phy) desc
Union all
Select distinct top 3 max(chem) from studata group by chem order by max(chem) desc