用with關鍵詞來簡化presto queries

最近學到的,使用with來簡化query,用起來想先create一些臨時的table,這樣可以避免寫嵌套的subqueries。效果應該是一樣的

例子如下:

with temp1 as (
  select a, b from table1
),
temp2 as (
  select c, d from table2
)
select 
  temp1.a,
  temp2.c
from 
  temp1
join
  temp2
on 
  temp1.b = temp2.d

Leave a Comment

Your email address will not be published.