字段列表中的未知列 - 分区

时间:2013-03-13 10:33:03

标签: mysql

此查询将返回错误(字段列表中的未知列numero_propostas)。我想要的是这样的:

SELECT COUNT(*) as numero_propostas, 
       total as total, 
       (numero_propostas / total) as divisao 
FROM ConsultaArtigos2 AS ca
...

正确的方法是什么?

2 个答案:

答案 0 :(得分:1)

SELECT COUNT(*) as numero_propostas, 
       total as total, 
       (COUNT(*)/ total) as divisao 
FROM ConsultaArtigos2 AS ca...

答案 1 :(得分:1)

在MySQL查询语句中,您必须使用引用位置的列名

  SELECT COUNT(*) as numero_propostas, 
         total as total, 
         (COUNT(*) / total) as divisao 
   FROM ConsultaArtigos2 AS ca