Skip to content

Instantly share code, notes, and snippets.

@2color
Created September 9, 2021 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2color/64d19a5a3fefc52470388a76dba1329e to your computer and use it in GitHub Desktop.
Save 2color/64d19a5a3fefc52470388a76dba1329e to your computer and use it in GitHub Desktop.
SELECT `main`.`User`.`id`, `main`.`User`.`email`, `main`.`User`.`city`, `main`.`User`.`name`, `aggr_selection_0_Post`.`_aggr_count_posts` FROM `main`.`User` LEFT JOIN (SELECT `main`.`Post`.`authorId`, COUNT(*) AS `orderby_aggregator` FROM `main`.`Post` GROUP BY `main`.`Post`.`authorId`) AS `orderby_0_Post` ON (`main`.`User`.`id` = `orderby_0_Post`.`authorId`) LEFT JOIN (SELECT `main`.`Post`.`authorId`, COUNT(*) AS `_aggr_count_posts` FROM `main`.`Post` GROUP BY `main`.`Post`.`authorId`) AS `aggr_selection_0_Post` ON (`main`.`User`.`id` = `aggr_selection_0_Post`.`authorId`) WHERE 1=1 ORDER BY COALESCE(`orderby_0_Post`.`orderby_aggregator`, ?) DESC LIMIT ? OFFSET ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment