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.