生成与 SQL 中的一组列相同的 UUID
有人可以建议一种编写 SQL 查询的方法,该查询将生成一个唯一的 UUID,该 UUID 与 amazon athena 中的一组列相同。
例如,我有一个这样的表,我想在其中为 columns1、columns2 和 columns3 创建一个 UUID。
column1 | column2 | column3 | column 4
2016 | 101 | 1 | 25
2016 | 101 | 1 | 59
2017 | 105 | 2 | 57
2017 | 105 | 2 | 78
输出 1 必须类似于
ID | column1 | column2 | column3 | column 4
UUID-1 | 2016 | 101 | 1 | 25
UUID-1 | 2016 | 101 | 1 | 59
UUID-2 | 2017 | 105 | 2 | 57
UUID-2 | 2017 | 105 | 2 | 78
输出 2:应该看起来像
ID | count |column1 | column2 | column3
UUID-1 | 2 |2016 | 101 | 1
UUID-2 | 2 |2017 | 105 | 2
我了解可以对输出 1 进行分组以生成输出 2。有人可以建议我如何生成输出 1 吗?
谢谢。
Can someone pls suggest a way to write SQL query which would generate a unique UUID which would be same for a group of columns in amazon athena.
For example, i have a table like this, where i want to create a UUID for columns1, columns2 and columns3.
column1 | column2 | column3 | column 4
2016 | 101 | 1 | 25
2016 | 101 | 1 | 59
2017 | 105 | 2 | 57
2017 | 105 | 2 | 78
Output 1 must look like
ID | column1 | column2 | column3 | column 4
UUID-1 | 2016 | 101 | 1 | 25
UUID-1 | 2016 | 101 | 1 | 59
UUID-2 | 2017 | 105 | 2 | 57
UUID-2 | 2017 | 105 | 2 | 78
Output 2: should look like
ID | count |column1 | column2 | column3
UUID-1 | 2 |2016 | 101 | 1
UUID-2 | 2 |2017 | 105 | 2
I understand that grouping can be done on output 1 to generate output 2. Can someone suggest, how i can generate output 1 ?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试使用
uuid()
函数。编辑
我看到您编辑了您的问题,您可以尝试使用子查询和自连接获取输出1,
另一种方式您可以尝试使用
max
窗口函数来为每个<获取一个GUID代码>列1 ,<代码>列2 ,<代码>列3 列。You can try to use
uuid()
function.EDIT
I saw you edit your question, you can try to use subquery and self join get output1
another way you can try to use
max
window function to get only one GUID percolumn1
,column2
,column3
columns.