SELECT *
FROM case_study
ORDER BY CASE WHEN expiry_date_case > CURDATE() THEN 1 END
WHEN expiry_date_case IS NULL THEN 2 Desc END
WHEN expire_date_case < CURDATE() THEN 3 Desc END;
When I am trying to run this query i am getting error as
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHEN expiry_date_case IS NULL THEN 2 Desc END WHEN expire_date_case < CURDATE() ' at line 4
Where am i doing wrong?
Try
SELECT *
FROM case_study
ORDER BY CASE WHEN expiry_date_case > CURDATE() THEN 1
WHEN expiry_date_case IS NULL THEN 2
WHEN expire_date_case < CURDATE() THEN 3 END Desc
You have too many End
's and Too many desc
's
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With