我的代码返回错误错误代码:1172.当我运行下面的代码时,结果包含了不止一行:
delimiter //
create function purchase_status(customernumber int) returns varchar(100) reads sql data
begin
declare purchase_state varchar(100);
select
case
when amount < 25000 then "Silver"
when amount between 25000 and 50000 then "Gold"
else "Platinum"
end as purchase_state2 into purchase_state
from payments;
return purchase_status;
end//
#drop function purchase_status;
select customernumber,customername,purchase_status(customernumber) as purchase_status
from customers;
我不知道该怎么称呼它。
1条答案
按热度按时间wqsoz72f1#
如果使用**
into purchase_state
**,则函数内的Select
子句必须返回一行。您可能忘记了
customernumber
或SUM(amount)
上的WHERE
子句,而不是amount。示例: