clear markdown feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3799354 fiddles created (41679 in the last week).

create table leads (lead_id int, status int, owner int); insert into leads values (3653, 18, 6585993); insert into leads values (3984, 3, 6585993); insert into leads values (4100, 18, 6585993); insert into leads values (8916, 21, 6585993); insert into leads values (20329, 1, 6585993);
 hidden batch(es)


SELECT lead_id, status, owner FROM leads WHERE owner = 6585993 AND ((`status` = 1) OR (`status` = 21) OR (`status` = 3)) ORDER BY CASE `status` WHEN 1 THEN 0 WHEN 21 THEN 1 WHEN 3 THEN 2 END LIMIT 1 ;
lead_id status owner
20329 1 6585993
 hidden batch(es)