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 o.amount desc;

为什么我会收到以下错误?:

消息 8127,级别 16,状态 1,第 5 行列“orders.amount”在 ORDER BY 子句中无效,因为它不包含在聚合函数或 GROUP BY 子句中。

4

2 回答 2

1

您只能selectorder by. 我想你的意思是:

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 Biggest_Purchase desc;
于 2013-04-21T20:00:47.483 回答
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;
于 2013-04-21T20:00:34.457 回答