Skip to content
Advertisement

Trying to get the 2 min(count()) with Ties

I allow myself to write a thread regarding a query I’m trying to make for hours now. I’m trying to get the name of the friend (friend.first_name) who refuses the most proposed dates for events.

To do this I’m counting the number of proposed date and ORDER BY ASC.

However, this does not take into account TIES.

What I’m looking for is the following result :

Expected Result

Furthermore, I’ve seen something with FETCH FIRST 1 ROW WITH TIES, however it does not seem to work with MySQL (getting SQL syntax issue).

Finally, I’ve had found an alternative using a function :

However, the issue is that, I need to put this into a view, but “View’s SELECT contains a variable or parameter”.

Therefore, I’m looking for another alternative or a solution to fix this issue.

P.S. : here is an MLD :

MLD

Advertisement

Answer

View is not required, a query result could be used as subquery

On MySQL 8+, it can also use RANK()

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement