How to solve Oracle ora-00937 Error: not a single group grouping function?

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: