I have a table
id type left right
1 featured 1 2
2 default 3 1
3 default 5 2
4 default 2 7
5 featured 3 4
6 featured 3 2
7 day 1 3
8 default 12 42
I need output five id where type != day and sort it by sum(left + right) and sort it by featured, default
First, need all the featured type ORDERING by sum(left + right), than with type = dafule ordering by sum(left + right) LIMIT 5
What I want to get:
5, 6, 1, 8, 4
Thanks!
The sort by “Featured” coming first is the IF() in the order by… if the type is “featured”, then use 1 as the sort basis, otherwise, use 2. Since you only have featured and default available (restricting “day” entries). Otherwise, that would be changed to a CASE/WHEN construct to account for other types