You can use count as follows:
Select case when greatest(id1,id2,id3) = id1 then 'id1'
When greatest(id1,id2,id3) = id2 then 'id2'
else 'id3' end grt
From
(Select count(case when id1 = 'ordered' then 1 end) as id1,
count(case when id2 = 'ordered' then 1 end) as id2,
count(case when id3 = 'ordered' then 1 end) as id3
From t) t
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…