使用group by获取两个非聚合数据的方法 [英] Way to get Two non aggregated data using group by

查看:264
本文介绍了使用group by获取两个非聚合数据的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这是一个奇怪的问题,但我别无选择
我有一个secnario,其中我需要三列
例如:经纪人,上限,股份

HI , I think this a kind of weird question but i have no choice
i had a secnario where i need three columns for
example: broker, cap, shares

select broker,cap,sum(shares) from table
group by broker



我知道无法获取上述数据,但是有什么方法可以代替使用group by或使用group by



I know it is not possible to get the data as above but is there any way i can get rather than using group by or with using group by

推荐答案

解释,不太了解您想要什么样的结果.原始数据和所需结果的示例将有所帮助.无论如何,只是在这里猜测需要,所以您尝试使用分区.像这样的东西:
Based on your explanation, didn''t quite understand what kind of result you would like to have. An example for the original data and the desired result would help. Anyhow, just guessing the need here so have you tried using partitioning. Something like:
select broker,
   cap,
   sum(shares) over (partition by broker) 
from table


这篇关于使用group by获取两个非聚合数据的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆