Oracle 第六單元 子查詢

2021-09-21 02:25:06 字數 927 閱讀 3661

單行比較示例

誰的薪水比abel高

select last_name

from employees

where salary > (select salary from employees where last_name = 'abel');

注:

單行比較必須對應單行子查詢(返回單一結果值的查詢);比如= , >

多行比較必須對應多行子查詢(返回乙個資料集合的查詢);比如 in , > any, > all 等

誰的薪水最低

select employee_id, last_name

from employees

where salary = (select min(salary) from employees)

多行比較

小於任何乙個it部門人員薪水的人員

select employee_id

,last_name

,job_id

,salary

from employees

where salary < any (select salary from employees where job_id = 'it_prog')

and job_id <> 'it_prog';

注:小於所有it部門人員薪水的人員
select employee_id

,last_name

,job_id

,salary

from employees

where salary < all (select salary from employees where job_id = 'it_prog')

and job_id <> 'it_prog';

注:

HIVE 第六章 查詢二

不同型別比較 不同型別的數字float double做比較,要注意0.2float大於0.2double 可以cat 0.2 as float order by and sort by hive的order by是全部資料的排序,在乙個reduce中處理排序,預設公升序。效率比較低,通常跟limit...

第六章 查詢效能優化

如果查詢是乙個任務,那麼它由一系列子任務組成,每個子任務都會消耗時間,優化查詢其實就是優化子任務 要麼消除一些子任務 要麼減少一些子任務執行的次數 要麼加快子任務的執行速度 查詢效能低下的最基本原因就是訪問的資料太多,可以這樣分析 如果發現掃瞄了大量資料,卻只返回少量的資料行,可以這樣優化 太多的表...

第六節 內聯接查詢 外聯接查詢

view code 內聯接 where select s.sname as姓名,m.score 成績from students s,stumark m where s.id m.stuid 三表聯接查詢 select s.sname 姓名,m.score 成績,c.coursename 課程from...