我试图在销售表中显示唯一的customer_ID列表。
经过几次尝试后我达到了这个代码,但是没有输出,我不确定它是否是写结构。有什么帮助吗?declare
c_id int;
begin
select max(unique(customer_ID)) into c_id from sales;
LOOP
DBMS_OUTPUT.PUT_LINE ('Employee Nnumber: ' || c_id);
end loop ;
end;
/
答案 0 :(得分:1)
根据您问题的文字,我的猜测是您正在寻找类似
的内容BEGIN
FOR c IN (SELECT DISTINCT customer_id FROM sales)
LOOP
dbms_output.put_line( 'Customer ID: ' || c.customer_id );
END LOOP;
END;
当然,您需要在所使用的任何工具中启用dbms_output
才能查看输出(set serveroutput on;
中的SQL*Plus
)。