2023-08-11
閱讀量:
2277
CDA數(shù)據(jù)分析一級教材SQL語句10
查詢員工的工資級別,3000 及以上為高,1500 及以下為低,其余為中
-- 使用 if 函數(shù)
select ename,sal,
if(sal>=3000,'高,if(sal<=1500,低,中')) 工資級別
from emp;-- 使用 case 邏輯表達式
select ename,sal,
case when sal>=3000 then r高
when sal<=1500 then 低 else中 end 工資級別
from emp;
-- 聚合函數(shù),得到公司所有員工的平均工資
select avg(sal) 平均工資 from emp;






評論(0)


暫無數(shù)據(jù)
推薦帖子
0條評論
1條評論
0條評論