Skip to content
Advertisement

How to combine two queries? MySQL

How can i combine my two queries?
1:

This query is finding dialogs where more than 10 messages and lasted more than an hour.

2:

The second query selects two last rows for each dialogs.

So, what i want is select last two rows for each dialogs that lasted more than an hour and where more than 10 messages. I want to show them on the dialog preview page.

Sorry for my english it isn’t my native language.

Advertisement

Answer

You can use window functions for all these calculations:

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