-
-
Save nizom333/498970d5edf4f940bda58d0274dac750 to your computer and use it in GitHub Desktop.
#SQL #MAXIMUM #WITHOUT_GROUP_BY #SPEED #QUERY
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT maintable.* | |
FROM TABLE_NAME maintable | |
LEFT OUTER JOIN TABLE_NAME temporarytable | |
ON maintable.GROUPING_BY_COLUMN = temporarytable.GROUPING_BY_COLUMN | |
AND maintable.COLUMN_WHERE_THE_MAXIMUM_IS_NEEDED < temporarytable.COLUMN_WHERE_THE_MAXIMUM_IS_NEEDED | |
WHERE temporarytable.COLUMN_WHERE_THE_MAXIMUM_IS_NEEDED IS NULL | |
ORDER BY PRIMARY_KEY_COLUMN DESC | |
LIMIT 50; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment