Is this homework or an interview coding question?
@tykus
This is interview coding question
@Mohamed_Hammad are you sure the task is to get others to answer the question? Are you allowed to bring us to the interview as well to explain the code?
@Sinnbeck This is a question in an interview that ended, and I could not answer it. I would like to know the correct answer, nothing more than that
@Mohamed_Hammad depending on your choice / version of database; you need either (i) a greatest-n-per-group query or (ii) a window function.
That is basic sql, with a sum and some group bys.
As @tykus pointed out the syntax would differ depending on the RDBMS of choice.
Please sign in or create an account to participate in this conversation.