CYBER WEEK - EXTRA SAVINGS EVENT
TRY A FREE LESSON

Answers to SQL Formatting

Hey DQ-Team,

thank you for the great SQL-Training. I really enjoy the course and instructions.

I came across this code as the proposed solution to mission-screen 255-4 Screen Link.

SELECT Major, Major_category FROM recent_grads
WHERE Major_category IN (select Major_category from recent_grads
group by Major_category
order by SUM(Total) DESC
limit 5)

I do not think it adheres to the style guide you introduced in an earlier mission.
Being new to SQL, it helps me to see queries which are formatted according in a uniform convention - I know what to look out for and see familiar patterns.

It would help me personally and maybe other learners, if all answers were formatted according to the style guide. I could then check, if not only my code is correct but also, if my formatting is done in a way that other users can follow.

Anyways, keep up the great work!
Best
Tim

PS: I would have formatted the solution like this:

SELECT Major, Major_category
  FROM recent_grads
 WHERE Major_category in (SELECT Major_category
                            FROM recent_grads
                           GROUP BY Major_category
                           ORDER BY SUM(Total) DESC
                           LIMIT 5)
4 Likes

Hey, Tim. Sorry for the late reply.

This has been fixed. It was already on our radar. The reason why we didn’t get to it earlier was that we had just started making changes to the content, and we were working starting from the first mission. We hadn’t gotten to this yet.

Thanks!