Back to questions
This SQL GROUP BY exercise uses real data from a LinkedIn SQL Interview question which is a bit too hard to tackle right now, so we'll solve an easier variant of the interview question.
Suppose you are given a table of candidates and their skills. How many candidates possess each of the different skills? Sort your answers based on the count of candidates, from highest to lowest.
Here's the solution:
Since we have to count candidates, that's a hint to use the aggregate function!
We also want to report our count FOR EACH SKILL... which means in your head, know that we'll !
Finally, because we want to sort answers based on the count of candidates, from highest to lowest, that's a job for . We need that DESC keyword, because the default is to sort ASC (ascending), which for numerical data means lowest to highest (which is NOT what the problem wants!).