Skip to content

Instantly share code, notes, and snippets.

@csharpforevermore
Forked from SauloSilva/case.sql
Created June 3, 2019 00:07
Show Gist options
  • Save csharpforevermore/c0b2feb6c0fbc69abdcf522712e1571a to your computer and use it in GitHub Desktop.
Save csharpforevermore/c0b2feb6c0fbc69abdcf522712e1571a to your computer and use it in GitHub Desktop.
sql case
SELECT STRAIGHT_JOIN categories.id, categories.title, categories.game_count, categories.display_order FROM `categories` INNER JOIN `category_namespaces` ON `category_namespaces`.`category_id` = `categories`.`id` WHERE `categories`.`type` IN ('ClickJogos::GameCategory') AND `categories`.`published` = 1 AND (category_namespaces.namespace = 'jgo') ORDER BY
CASE
WHEN categories.id LIKE '447%' THEN 1
WHEN categories.id LIKE '448%' THEN 2
ELSE 3
END, categories.game_count DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment