Previously, I encountered this problem when writing Oracle SQL statements. Here is a record
Problem Description: ora-00937: not a single group grouping function
Cause of the problem: in the select statement, you are querying the value of a column, in which there is an aggregate function
Originally, I wrote SQL like this
--Find the receipt delivery point, delivery delivery point, and number of delivery packages for a delivery order--
select R_DELIVEPOINT_ID,S_DELIVEPOINT_ID,SUM(PACK_NUM) PACK_NUM from TMS_DELIVERY;
The aggregate function sum () is used to solve this problem
If you want to solve this problem, the SQL syntax can be changed as follows:
1) Disaggregate function
--Find the receipt delivery point, delivery delivery point, and number of delivery packages for a delivery order--
select R_DELIVEPOINT_ID,S_DELIVEPOINT_ID,PACK_NUM from TMS_DELIVERY;
2) Support aggregate function (add group by)
--Find the receipt delivery point, delivery delivery point, and number of delivery packages for a delivery order--
select R_DELIVEPOINT_ID,S_DELIVEPOINT_ID,SUM(PACK_NUM) PACK_NUM from TMS_DELIVERY
group by R_DELIVEPOINT_ID,S_DELIVEPOINT_ID;
Similar Posts:
- Usage of within group in Oracle
- Error: not a group by expression [How to Solve]
- MYSQL Error: Invalid use of group function [How to Solve]
- [Solved] must appear in the GROUP BY clause or be used in an aggregate function
- Oracle error: not a group by expression [How to Solve]
- [Solved] must appear in the GROUP BY clause or be used in an aggregate function
- Hive SemanticException:Expression not in GROUP BY
- [Solved] MYSQL Command gruop by Error: this is incompatible with sql_mode=only_full_group_by
- [Solved] SELECT list is not in GROUP BY clause and contains nonaggregated
- [Thinkphp6] Connect to SQL Server and use subquery to report error: when subquery is not introduced with exists, only one expression can be specified in the selection list