Zhuuu ZZ HIVE 五 高階查詢

2021-10-09 13:32:01 字數 2184 閱讀 1949

select1;

select

[distinct

] column_nam_list from table_name;

select

*from table_name;

select

*from employee where name!=

'lucy'

limit

5;

-- cte語法

with t1 as

(select …)

select

*from t1

-- 巢狀查詢示例

select

*from

(select

*from employee) a;

set hive.support.quoted.identifiers = none;

--查詢欄位名以o開頭的該字段的值。

select

`^o.*`

from offers;

交叉連線:cross join --返回行的笛卡爾乘積

隱式連線:implicit join --幾乎等同與內連線

join發生在where子句之前

將顧客表、部門表、商品表資料存入hive

hdfs dfs -put 檔案路徑 hdfs**資料夾路徑
select

*from customers where customer_city=

'new york'

;

select

count

(distinct order_customer_id)

from orders;

select

*from products limit

5;

with t1 as

(select

*from customers)

select concat(customer_fname,customer_lname)

from t1;

select concat(customer_fname,customer_lname)

from

(select

*from customers)a;

select

`customer_(

.|.|

.name)

`from customers;

select customer_id from customers

left

join orders on customer_id=order_customer_id

where order_id is

null

;

可進行不等值連線

開啟join操作

mapjoin操作不支援:

可以在頂層查詢中使用(0.13.0之後)

order by, sort by, cluster by, distribute by 和limit適用於合併後的整個結果

集合其他操作可以使用join/outer join來實現

差集、交集

Sql Server DateBase 高階查詢

認識總是隨著你的知識積累而不斷地改變,前面還信誓旦旦的將查詢是一種條件,現在想豐富一下自己的認識,資料庫中存放了大量的資料,對於不同的dbms,它們對於資料的組織方式是不同的,sql將資料以二維表的形式組織,查詢一詞是由於我們人因為一些問題需要檢視需要的資料,所以才有查詢一詞。高階查詢的出現是由於出...

並查集高階

n 個孤立點,m 次加邊操作,設 l i,j 表示結點 i 和 j 最早在第 l i,j 次操作後連通。在 m 次操作後,求出 sum n sum n l i,j 的值。解法 quad 並查集的時候記錄子樹大小即可。n 個孤立點,m 次加邊操作,q 次詢問,每一次問 u 和 v 最早在第幾次操作後連...

並查集入門 高階

入門解釋 高階解釋 入門篇模板 define arr size 100 int pre arr size int deep arr size void init int pre find int x return pre find pre x 遞迴查詢 void unite int x,int y ...