我有例如价值观' X'' Y'' Z'' '在列myValue
中并想做一些像select max(myValue)
这样的事情所以我想要一个值,一个值最高的值,其中X = 1,Y = 2,Z = 0
答案 0 :(得分:1)
select max(
case myValue
when 'X' then 1
when 'Y' then 2
when 'Z' then 0
end) myValue
from myTable
答案 1 :(得分:-1)
(select max(PurDate) as mb,prodid as pd
from batch group by ProdId ) as rs
on p.RndId = b.ProdId
and p.ComId = c.RndId
where b.PurDate = rs.mb
and b.ProdId = rs.pd
and p.RndId in (select distinct prodid
from TranItem as ci, TranMain
as tm
where tm.RndId = ci.TranId
and tm.Invdate between '2016-May-01' and '2016-May-31')