Posts by Ady • 21 points
1 post
-
2
votes2
answers308
viewsA: Sort by larger ID and group the similar
SELECT id, title, related FROM produtos ORDER BY CASE WHEN related IS NULL THEN 1 ELSE 0 END, related; Upshot: id title Related 2 shirt 123456 4 sweatshirt 123456 1 tenis NULL 3 calca NULL 5 NULL…