他和
SELECT
name,
CASE
WHEN grade>=80 THEN 'A'
WHEN 70<GREDE<79 THEN 'B'
WHEN 60<GREDE<69 THEN 'C'
ELSE
'D'
END AS DJ
From www
百度一下sql里面的case when ,就是if else的功能。
select case when grade >=80 then 'A' when grade >=70 and grade <79 then 'B' when grade >=60 and grade <69 then 'C' else 'D' end as level from table