sql - 如何在oracle sql中对已经分组的数据集进行分组
问题描述
我想首先根据“Roll”对数据进行分组,然后根据“名称”将其进一步分组,并使用不同的“标记”。我已经使用Group by 和 have 对数据进行了分组,但我不确定如何进一步对其进行分组。
解决方案
如果我理解正确,您希望roll
/name
对具有多个不同的值。您可以使用窗口函数执行此操作:
select distinct roll, name, marks
from (select t.*, count(distinct marks) over (partition by roll, name) as cnt
from t
) t
where cnt > 1;
推荐阅读
- arrays - 我们如何在 emu8086 程序集中获得数组长度?
- java - ByteArrayOutputStream.toString() 给出一个垃圾值
- javascript - PWA 中没有添加到主屏幕弹出窗口
- android - 带有无用信息的 Android Crashlytics 日志,如何定位错误?
- node.js - 使用Vue js调用axios发布请求时出现CORS和网络错误
- java - Spring Boot 捕获 SSLHandshakeException
- flutter - 如何在颤动中获取地图的索引键?
- python - 如何使用 Beautifulsoup 或 Selenium 提取图像的标题和 src?
- c++ - 解析char数组并且不删除分隔符c ++
- reactjs - 无法让属性依赖注入在 React 项目中工作