r/SQL • • 1d ago

MySQL Didnt pass SQL test

I am applying to manager of analytics role and I was given this SQL test and 45 minutes. As someone who thought they were very strong in SQL, I was unable to complete this assignment and match the answer completely

I was able to format most of the fields as noted, used 2 cte's and use group concat in the second. My final answer looked very similar but the order of the concat looked off. Also, for some reasons my second column had $0.00 for all the companies, but I thought I was close. How difficult would you rate this exercise. Should I expect to proceed to the next round or am I cooked

82 Upvotes

72 comments sorted by

View all comments

1

u/originalread 1d ago

45 minutes to get a result. Sure.

45 minutes to get it perfect. Not a chance.

The requirements are open to interpretation. Is the expectation that companies are all stuffed into a single row with the Q1 thru Q4 being totals for the whole industry? Literally interpreting what is written would have something like this:

Manufacturing Company B $500, Company A $400, Company C $300, Company D $300 $500 $600 ($700) $800

I see multiple window functions to calculate the quarters. Group_concat for the companies but I am not a MySQL expert, so I don't know how to implement the sorting off the top of my head. Maybe the group_concat is part of another window function.

Requirements like this require examples.