Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql Group by/Order by/Where/ON子句中不能使用Group或聚合函数(min()、max()、sum()、count()、…等)_Sql_Zoho - Fatal编程技术网

Sql Group by/Order by/Where/ON子句中不能使用Group或聚合函数(min()、max()、sum()、count()、…等)

Sql Group by/Order by/Where/ON子句中不能使用Group或聚合函数(min()、max()、sum()、count()、…等),sql,zoho,Sql,Zoho,似乎我不能按奇数列的计数排序,因为我已经看到很多例子,在order by语句中使用了count()。我正在使用Zoho分析。 我的问题是: SELECT "Lead Owner Name", "Lead Source", count("Lead Source") FROM "Leads" group by "Lead Owner Name", "Lead Source" ord

似乎我不能按奇数列的计数排序,因为我已经看到很多例子,在order by语句中使用了count()。我正在使用Zoho分析。 我的问题是:

SELECT "Lead Owner Name", "Lead Source", count("Lead Source")
FROM "Leads"
group by "Lead Owner Name", "Lead Source"
order by count("Lead Source") DESC;
尝试使用别名:

SELECT "Lead Owner Name", "Lead Source", count("Lead Source") as cnt
FROM "Leads" 
GROUP BY "Lead Owner Name", "Lead Source" 
ORDER BY cnt DESC;

大多数数据库支持按顺序排列的任意表达式。但是,有些表达式要求排序表达式实际上是一列,并且它们不会检测
SELECT
表达式何时与
orderby
表达式相同。我以前遇到过这个问题(我想是使用Hive),我只是认为这可能在您的环境中起作用。

您可以改为按列别名排序吗?