Reputation: 4607
I have table with fields task_priority
, task_completed_time
,task_completed
. Completed colume have values 0
and 1
and it is a primary sort. I want to make secondary sort to be priority
if completed
is 0
and completed_time
if completed
is 1
. How can i get it?
Upvotes: 1
Views: 616
Reputation: 4607
after some typo fixes i made it:
SELECT * FROM task_table
WHERE (task_name LIKE ? )
ORDER BY task_completed ASC,
CASE task_completed
WHEN 0 THEN task_priority
WHEN 1 THEN task_completed_time
END DESC
Upvotes: 4