0

我有以下查询

select 
    sub.W
from 
    (select 
        W, count(W) as N
     from L
     group by W) sub
where 
     sub.N >= max(sub.N)

我得到这个错误:

错误代码 1111,SQL 状态 HY000:无效使用组函数
第 1 行,第 1 列

怎么了?

4

2 回答 2

3

你有没有试过这个:

select sub.W
from 
(
       select W, count(W) as N
       from L
       group by W
) sub
where n >= (select max(N)
            from
            (
              select count(W) as N
              from L
              group by W
            ) x)

请参阅带有演示的 SQL Fiddle

于 2012-10-24T23:08:03.170 回答
0

尝试:

select sub.W    
from 
(
       select W, count(W) as N
       from L
       group by W
) sub    
where sub.N >= (select max(N)
                from (
                       select W, count(W) as N
                       from L
                       group by W
                      ) sub2)
于 2012-10-24T23:02:05.443 回答