完全小白,求教大佬关于我写的sql语句问题。我感觉自己逻辑上没有错。为什么运行不出来呢。求指正我哪里错了。
我的sql:select * from orders where purch_amt>(select avg(purch_amt) from orders group by customer_id
完全小白,求教大佬关于我写的sql语句问题。我感觉自己逻辑上没有错。为什么运行不出来呢。求指正我哪里错了。
我的sql:select * from orders where purch_amt>(select avg(purch_amt) from orders group by customer_id
select o.* from orders as o
join (select customer_id, avg(purch_amt) as avg_amt from orders group by customer_id) as a
on o.customer_id=a.customer_id
where o.purch_amt>a.avg_amt