用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 Reply

Your email address will not be published. Required fields are marked *