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.
假设我有一张这样的桌子。
A | B ----- 1 | 4 7 | 8 1 | 3 1 | 2 4 | 5 3 | 5 2 | 5 7 | 8
尽管它1是列中最常见的值A并且5是列中最常见的值B(可以用 a 非常简单地检查COUNT()),但我正在寻找的结果是该对<7, 8>,因为该对出现了两次。
1
A
5
B
COUNT()
<7, 8>
那么如何从表中获取最常见的值序列,因为我有n需要使用的列。
n
select A, B, count(*) as freq from MyTable group by A, B order by count(*) desc limit 1