Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个两列文件
| 对象 | 集团 |
我可以运行什么查询来查看对象是否有多个不同的组?
例如,
对象一个 1 对象a 2 对象 b 3
对象 b 很好,因为它有 1 个不同的组,但对象 a 有两个。
有人可以帮忙吗?
谢谢
我认为你需要这个:
SELECT T.object, COUNT(*) FROM (SELECT DISTINCT object, group FROM <yourtablename>) T GROUP BY T.object HAVING COUNT(*) > 1
这将返回具有> 1组的所有对象。