Oracle数据库允许以下查询:
select col1 from table order by col2;
select count(col1) from table group by col2;
似乎order/group by子句中的列不需要在select子句中。但是,tutorialspoint: SQL - ORDER BY Clause告诉我的不是。那么,上面提到的只是甲骨文吗?
最佳答案
这个教程完全错了。order by
可以包含查询对象中的任何列,无论它们是否在选择列表中。
Agroup by
则相反。选择列表中的任何非聚合列都必须包含在group by
中。