从雅典娜查询的两个桌子中创建景色
基本上,我的用例是我在雅典娜中创建一个视图,但我想根据表中的一列给出的日期(snapshot_date)从两个表(snapshot_date)中选择数据。怎么做?我找不到该语法,因为
SELECT
baseline_year
, marketplace
, locale
, snapshot_time
, ...
FROM
table1
我想实现快照时间小于2022-05-01,然后使用表2,否则请使用表1。 我们可以从任何形式的条件中加入吗?我已经探讨了我们可以在列上执行条件时使用case_,但不确定可以使用吗?
Basically my use case is that I am creating a view in athena but i want to select the data from two tables depending on the date (snapshot_date) which is given by a column in the tables. How to do it? I am not finding the syntax for that
SELECT
baseline_year
, marketplace
, locale
, snapshot_time
, ...
FROM
table1
I want to achieve something like if snapshot time is less than 2022-05-01, then use table 2 otherwise use table 1.
Can we any kind of conditioning in FROM? I have explored that we can use CASE_WHEN for performing conditions on columns, but not sure that can be used in FROM?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我没记错的话,如果SnapShot_Time早于2022-05-01,则应使用Table2,如果SnapShot_Time大于或等于2022-05-01 ,无论哪种shapshot_time 这两个桌子有。
If I am not mistaken, you meant to use table2 if the snapshot_time is earlier than 2022-05-01 and use table1 if the snapshot_time is greater than or equal to 2022-05-01 REGARDLESS of what shapshot_time those two tables have.
您可以继续进行参数化视图,尝试创建一个函数:
然后创建视图:
You can proceed with a parametrized view, try to create a function:
Then create the view :