以下是我的疑问:
select MAX(o.amount)as Biggest_Purchase , c.cust_fname, c.cust_lname
from orders o, customer c
where o.cust_num = c.cust_num
group by c.cust_fname, c.cust_lname
order by o.amount desc;
为什么我收到以下错误?:
Msg 8127,Level 16,State 1,Line 5 ORDER BY子句中的“orders.amount”列无效,因为它不包含在聚合函数或GROUP BY子句中。
答案 0 :(得分:1)
您只能在select
的{{1}}子句中指定列。我想你的意思是:
order by
答案 1 :(得分:0)
select MAX(o.amount)as Biggest_Purchase , c.cust_fname, c.cust_lname
from orders o, customer c
where o.cust_num = c.cust_num
group by c.cust_fname, c.cust_lname
order by max(o.amount) desc;