oracle - SQL: not a single group function .... not a GROUP BY expression -
this question has answer here:
- ora-00979 not group expression 7 answers
i have number of tables detailing shop's customers , sales, etc.
i want find minimum sale price; i.e. single result returned sql expression.
in order result make sense want join customer_sale table customer table (so customer in question have his/her name returned).
using following code
select cust_order.cust_id, customer.fname, customer.lname, min(sale_price) cust_order inner join customer on cust_order.cust_id = customer.cust_id group cust_order.cust_id having min(sale_price) = (select min(sale_price) cust_order group cust_id) in oracle 11g throws following error:
error @ line 1: ora-00979: not group expression
which makes sense return single result.
however deleting group clauses causes dbms throw following error:
select cust_order.cust_id, customer.fname, customer.lname, min(sale_price) cust_order inner join customer on cust_order.cust_id=customer.cust_id having min(sale_price) = (select min(sale_price) cust_order) error @ line 1: ora-00937: not single-group group function
is there additional nesting have statement execute correctly?
if you're getting min entire table, perhaps this:
select distinct cust_order.cust_id, customer.fname, customer.lname, sale_price cust_order inner join customer on cust_order.cust_id=customer.cust_id sale_price = (select min(sale_price) cust_order) i'm not sure if need distinct or not, or how data looks.
Comments
Post a Comment