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.
我有一个存储了数百万个三元组的 SQL 数据库。大部分三元组至少重复一次。计算数据库中每个三元组出现的次数的最实用方法是什么?谢谢。
假设“三元组”由三列c1、c2和组成c3,您可以使用group by来计算不同的元组:
c1
c2
c3
group by
select c1, c2, c3, count(1) from mytable group by c1, c2, c3
演示:http ://www.sqlfiddle.com/#!7/693c4/2