select max(qtd)
from (select count(int_re_usu) as qtd from tb_questionario_voar_resposta)
为什么这个查询不工作? 我想从所有计数SQL语法不正确
它说,不正确的语法附近“)”
任何ideias检索最大值?
select max(qtd)
from (select count(int_re_usu) as qtd from tb_questionario_voar_resposta)
为什么这个查询不工作? 我想从所有计数SQL语法不正确
它说,不正确的语法附近“)”
任何ideias检索最大值?
您需要在派生表的别名:
select max(qtd)
from (
select count(int_re_usu) as qtd
from tb_questionario_voar_resposta
) a
但是文森特指出,刚刚返回一行,我认为你是缺少一个组。你真的可以只是做:
select max(count(int_re_usu)) as qtd
from tb_questionario_voar_resposta
group by SomeColumn
试试这个你缺少一组由我觉得和使用别名中
select
max(d1.qtd)
from
(
select
count(int_re_usu) as qtd
from tb_questionario_voar_resposta
group by qtd
) as d1
group by d1.qtd
你想通过在子查询中放置组(或者只是删除它)。但是由于OP没有提到它,所以很难知道如何使用它。 – 2010-11-16 16:27:52
是的,你的权利..固定它谢谢。我只是想建议它,我不知道OP要什么.. – Vishal 2010-11-16 16:31:34
查询本身没有什么意义。子查询将始终返回一行(表中总行数),因此从一行中选择最大值将始终返回此行... – 2010-11-16 16:25:36
我认为您可能在子查询中缺少GROUP BY子句。写入的查询与子查询“select count(int_re_usu)as tt_questionario_voar_resposta”中的qtd一样“ – 2010-11-16 16:27:04
就像文森特说的 - 这没什么意义 - 你试图通过使用子查询来完成什么? – 2010-11-16 16:27:35