Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Mohamed_Hammad's avatar

Sql Query

Hello everyone I need to write this query This is the pdf that you can check the query https://drive.google.com/drive/folders/1XKvsbN9GE3-OQZtZBELE-Mhr7mBcAt4Z

0 likes
6 replies
tykus's avatar

Is this homework or an interview coding question?

1 like
Sinnbeck's avatar

@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?

1 like
Mohamed_Hammad's avatar

@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

tykus's avatar

@Mohamed_Hammad depending on your choice / version of database; you need either (i) a greatest-n-per-group query or (ii) a window function.

1 like
Tray2's avatar

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.

1 like

Please or to participate in this conversation.