首页 > 解决方案 > 雪花:加入两个选择语句

问题描述

免责声明:SQL 和 SNOWFLAKE的新手 ......所以在你从事反消费者滥用行为之前......

假设我有两个选择语句:

select foo,bar from baz as b;

select foo,bar,gee,whiz from qaz as q;

假设第二个 select 语句有一个连接:

select foo, bar, gee, whiz from qaz as q

left join data as d on (d.gee = q.gee)
where d.whiz = q.whiz
and q.foo is not NULL

现在,如何将这两个不同的选择组合成左连接?

select foo,bar from baz as b
left join

( select foo, bar, gee, whiz from qaz as q
  left join data as d on (d.gee = q.gee)
  where d.whiz = q.whiz and q.foo is not NULL
) this

on b.foo = this.foo
where b.bar = this.bar
order by b.foo desc
limit 1 

以上不起作用。在本地计算上述内容是不可能的:只有 20,000 行,pandas 占用超过 20gb 的内存。如何用 Snowflake 计算这个数据集?

标签: snowflake-cloud-data-platform

解决方案


推荐阅读