使用 COUNT(*) 和 INTO oracle sql
Using COUNT(*) and INTO oracle sql
我有select这样的陈述:
with input as
(select id,date,quantity
from
abc a,xyz z
.......)
select count(*)
from input t
where .....;
这个语句给我的结果是 0,我想使用这个 count=0 我的程序部分。我添加了 select count(*) 输出,现在看起来像这样:
select count(*) output
with input as
(select id,date,quantity
from
abc a,xyz z
.......)
select count(*)
from input t
where .....);
现在输出将不再是 0(零),因为它计算零本身的结果并将最终结果作为 1..我如何使用 INTO 语句 pass/hold 零或任何其他实际结果 ORACLE/SQL?
你会得到这样的结果:
declare
v_cnt number;
begin
with input as (
select id,date,quantity
from abc a join
xyz z
.......
)
select count(*) into v_cnt
from input t
where .....;
end;
我有select这样的陈述:
with input as
(select id,date,quantity
from
abc a,xyz z
.......)
select count(*)
from input t
where .....;
这个语句给我的结果是 0,我想使用这个 count=0 我的程序部分。我添加了 select count(*) 输出,现在看起来像这样:
select count(*) output
with input as
(select id,date,quantity
from
abc a,xyz z
.......)
select count(*)
from input t
where .....);
现在输出将不再是 0(零),因为它计算零本身的结果并将最终结果作为 1..我如何使用 INTO 语句 pass/hold 零或任何其他实际结果 ORACLE/SQL?
你会得到这样的结果:
declare
v_cnt number;
begin
with input as (
select id,date,quantity
from abc a join
xyz z
.......
)
select count(*) into v_cnt
from input t
where .....;
end;