Using ORDER BY with GROUP BY

You can also use the ORDER BY clause with GROUP BY. It will need to be placed after the GROUP BY clause, as shown in the following query: 

USE lahmansbaseballdb; 
SELECT playerid, teamid
FROM batting
WHERE playerid = 'aardsda01'
GROUP BY teamid, playerid
ORDER BY playerid, teamid;

The following screenshot shows the results of running the previous query: 

Here, you can see that the results are now ordered by playerid and teamid

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.216.249