Dovezile masurate pentru propunerile de directie (09.2026)

Backtest read-only pe productie: recunoasterea articolului la importul de
eFactura, contarea pe istoric de furnizor, identificarea partenerului la
importul de extrase, plafonul potrivirii facturii din textul bancii.
Include harta codului de import extrase, testul care confirma eroarea de
parsare BT si scripturile SQL reproductibile.

Propunerile care se sprijina pe ele:
COMUN/docs/cercetare/rec_directie_roacont_2026_09.md

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T8jmGHs29e9eyLgoMiLBHW
This commit is contained in:
2026-09-03 14:19:16 +03:00
parent d4a9c800ff
commit f9af574877
12 changed files with 2088 additions and 0 deletions

View File

@@ -0,0 +1,150 @@
set pagesize 0 linesize 200 feedback off heading off trimspool on
select 'FIRMA TOTAL VERDE3 CORECT NOI' from dual;
with sup as (select cod, max(id_partc) idf, min(dataact) d from VADECO.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from VADECO.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('VADECO',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from WERT.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from WERT.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('WERT',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from TURQUOISE.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from TURQUOISE.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('TURQUOISE',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from DRAFTC.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from DRAFTC.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('DRAFTC',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from FINELINE.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from FINELINE.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('FINELINE',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from ANNA.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from ANNA.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('ANNA',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from PASS.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from PASS.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('PASS',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from LEV.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from LEV.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('LEV',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from VIDD.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from VIDD.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('VIDD',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from INTERIOR.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from INTERIOR.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('INTERIOR',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from DRAFTD.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from DRAFTD.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('DRAFTD',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from COTOFANACONCEPT.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from COTOFANACONCEPT.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('COTOFANACONCEPT',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from LEIL2.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from LEIL2.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('LEIL2',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from CERAMOTERM.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from CERAMOTERM.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CERAMOTERM',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from DRAFTA.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from DRAFTA.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('DRAFTA',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from CIAO.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from CIAO.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CIAO',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from CLINIDERMA.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from CLINIDERMA.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CLINIDERMA',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from DOMINUS.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from DOMINUS.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('DOMINUS',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from CARAPETRU.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from CARAPETRU.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CARAPETRU',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from CAPIDAVATOUR.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from CAPIDAVATOUR.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CAPIDAVATOUR',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from CUX.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd)||trim(nvl(a.ascd,' ')) c from CUX.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CUX',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),7)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),7)||lpad(sum(case when s1 is null then 1 else 0 end),6) from u;
exit

View File

@@ -0,0 +1,150 @@
set pagesize 0 linesize 200 feedback off heading off trimspool on
select 'FIRMA TOTAL COV3 CORECT3 COV5 CORECT5' from dual;
with sup as (select cod, max(id_partc) idf, min(dataact) d from VADECO.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from VADECO.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('VADECO',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from WERT.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from WERT.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('WERT',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from TURQUOISE.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from TURQUOISE.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('TURQUOISE',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from DRAFTC.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from DRAFTC.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('DRAFTC',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from FINELINE.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from FINELINE.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('FINELINE',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from ANNA.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from ANNA.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('ANNA',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from PASS.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from PASS.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('PASS',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from LEV.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from LEV.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('LEV',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from VIDD.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from VIDD.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('VIDD',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from INTERIOR.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from INTERIOR.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('INTERIOR',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from DRAFTD.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from DRAFTD.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('DRAFTD',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from COTOFANACONCEPT.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from COTOFANACONCEPT.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('COTOFANACONCEPT',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from LEIL2.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from LEIL2.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('LEIL2',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from CERAMOTERM.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from CERAMOTERM.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CERAMOTERM',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from DRAFTA.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from DRAFTA.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('DRAFTA',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from CIAO.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from CIAO.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CIAO',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from CLINIDERMA.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from CLINIDERMA.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CLINIDERMA',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from DOMINUS.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from DOMINUS.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('DOMINUS',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from CARAPETRU.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from CARAPETRU.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CARAPETRU',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from CAPIDAVATOUR.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from CAPIDAVATOUR.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CAPIDAVATOUR',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
with sup as (select cod, max(id_partc) idf, min(dataact) d from CUX.act where nvl(sters,0)=0 and substr(scc,1,3)='401' and nvl(id_partc,0)>0 and dataact >= add_months(trunc(sysdate,'MM'),-36) and dataact < trunc(sysdate,'MM') group by cod),
deb as (select distinct s.cod, trim(a.scd) c from CUX.act a join sup s on s.cod=a.cod where nvl(a.sters,0)=0 and a.scd is not null and trim(a.scd) is not null and substr(a.scd,1,3)<>'442'),
sig as (select cod, listagg(c,'+') within group (order by c) sg from deb group by cod),
docs as (select s.cod, s.idf, s.d, g.sg from sup s join sig g on g.cod=s.cod where g.sg <> '401'),
ord as (select d.*, lag(sg,1) over (partition by idf order by d,cod) s1, lag(sg,2) over (partition by idf order by d,cod) s2, lag(sg,3) over (partition by idf order by d,cod) s3, lag(sg,4) over (partition by idf order by d,cod) s4, lag(sg,5) over (partition by idf order by d,cod) s5 from docs d),
u as (select * from ord where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CUX',18)||lpad(count(*),6)||lpad(sum(case when s1=s2 and s2=s3 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s1=sg then 1 else 0 end),8)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 then 1 else 0 end),6)||lpad(sum(case when s1=s2 and s2=s3 and s3=s4 and s4=s5 and s1=sg then 1 else 0 end),8) from u;
exit

View File

@@ -0,0 +1,24 @@
set pagesize 0 linesize 200 feedback off heading off trimspool on
select 'FIRMA PRIMITE LEGATE' from dual;
select rpad('VADECO',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from VADECO.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('WERT',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from WERT.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('TURQUOISE',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from TURQUOISE.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('DRAFTC',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from DRAFTC.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('FINELINE',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from FINELINE.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('ANNA',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from ANNA.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('PASS',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from PASS.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('LEV',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from LEV.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('VIDD',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from VIDD.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('INTERIOR',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from INTERIOR.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('DRAFTD',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from DRAFTD.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('COTOFANACONCEPT',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from COTOFANACONCEPT.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('LEIL2',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from LEIL2.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('CERAMOTERM',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from CERAMOTERM.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('DRAFTA',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from DRAFTA.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('CIAO',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from CIAO.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('CLINIDERMA',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from CLINIDERMA.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('DOMINUS',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from DOMINUS.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('CARAPETRU',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from CARAPETRU.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('CAPIDAVATOUR',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from CAPIDAVATOUR.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
select rpad('CUX',18)||lpad(count(*),7)||lpad(sum(case when nvl(id_fact,0)>0 then 1 else 0 end),7) from CUX.anaf_efactura where nvl(factura_emisa,0)=0 and xdata_act >= add_months(trunc(sysdate,'MM'),-12) and xdata_act < trunc(sysdate,'MM');
exit

View File

@@ -0,0 +1,163 @@
set pagesize 0 linesize 220 feedback off heading off trimspool on
select 'FIRMA LINII CUCONT EXACT OKEX NORM OKNO' from dual;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d, dt.id,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from WERT.anaf_efactura_detalii dt join WERT.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
sum(ac) over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) pe,
sum(ac) over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) pn,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('WERT',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when nvl(pe,0)>0 then 1 else 0 end),7)||lpad(sum(case when ac=1 and qe is not null and qe=ct then 1 else 0 end),5)||lpad(sum(case when nvl(pn,0)>0 then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn is not null and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d, dt.id,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from DRAFTC.anaf_efactura_detalii dt join DRAFTC.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
sum(ac) over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) pe,
sum(ac) over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) pn,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('DRAFTC',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when nvl(pe,0)>0 then 1 else 0 end),7)||lpad(sum(case when ac=1 and qe is not null and qe=ct then 1 else 0 end),5)||lpad(sum(case when nvl(pn,0)>0 then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn is not null and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d, dt.id,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from VADECO.anaf_efactura_detalii dt join VADECO.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
sum(ac) over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) pe,
sum(ac) over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) pn,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('VADECO',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when nvl(pe,0)>0 then 1 else 0 end),7)||lpad(sum(case when ac=1 and qe is not null and qe=ct then 1 else 0 end),5)||lpad(sum(case when nvl(pn,0)>0 then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn is not null and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d, dt.id,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from TURQUOISE.anaf_efactura_detalii dt join TURQUOISE.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
sum(ac) over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) pe,
sum(ac) over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) pn,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('TURQUOISE',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when nvl(pe,0)>0 then 1 else 0 end),7)||lpad(sum(case when ac=1 and qe is not null and qe=ct then 1 else 0 end),5)||lpad(sum(case when nvl(pn,0)>0 then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn is not null and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d, dt.id,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from FINELINE.anaf_efactura_detalii dt join FINELINE.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
sum(ac) over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) pe,
sum(ac) over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) pn,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('FINELINE',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when nvl(pe,0)>0 then 1 else 0 end),7)||lpad(sum(case when ac=1 and qe is not null and qe=ct then 1 else 0 end),5)||lpad(sum(case when nvl(pn,0)>0 then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn is not null and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d, dt.id,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from INTERIOR.anaf_efactura_detalii dt join INTERIOR.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
sum(ac) over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) pe,
sum(ac) over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) pn,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('INTERIOR',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when nvl(pe,0)>0 then 1 else 0 end),7)||lpad(sum(case when ac=1 and qe is not null and qe=ct then 1 else 0 end),5)||lpad(sum(case when nvl(pn,0)>0 then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn is not null and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d, dt.id,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from PASS.anaf_efactura_detalii dt join PASS.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
sum(ac) over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) pe,
sum(ac) over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) pn,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('PASS',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when nvl(pe,0)>0 then 1 else 0 end),7)||lpad(sum(case when ac=1 and qe is not null and qe=ct then 1 else 0 end),5)||lpad(sum(case when nvl(pn,0)>0 then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn is not null and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d, dt.id,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from CARAPETRU.anaf_efactura_detalii dt join CARAPETRU.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
sum(ac) over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) pe,
sum(ac) over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) pn,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CARAPETRU',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when nvl(pe,0)>0 then 1 else 0 end),7)||lpad(sum(case when ac=1 and qe is not null and qe=ct then 1 else 0 end),5)||lpad(sum(case when nvl(pn,0)>0 then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn is not null and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d, dt.id,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from LEV.anaf_efactura_detalii dt join LEV.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
sum(ac) over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) pe,
sum(ac) over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) pn,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('LEV',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when nvl(pe,0)>0 then 1 else 0 end),7)||lpad(sum(case when ac=1 and qe is not null and qe=ct then 1 else 0 end),5)||lpad(sum(case when nvl(pn,0)>0 then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn is not null and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d, dt.id,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from ANNA.anaf_efactura_detalii dt join ANNA.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
sum(ac) over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) pe,
sum(ac) over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) pn,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('ANNA',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when nvl(pe,0)>0 then 1 else 0 end),7)||lpad(sum(case when ac=1 and qe is not null and qe=ct then 1 else 0 end),5)||lpad(sum(case when nvl(pn,0)>0 then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn is not null and qn=ct then 1 else 0 end),5) from u;
exit

View File

@@ -0,0 +1,269 @@
set pagesize 0 linesize 220 feedback off heading off trimspool on
select 'FIRMA LINII CUCONT DENEX OKEX DENNO OKNO' from dual;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from WERT.anaf_efactura_detalii dt join WERT.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('WERT',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and qe is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qe=ct then 1 else 0 end),5)||lpad(sum(case when ac=1 and qn is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from DRAFTC.anaf_efactura_detalii dt join DRAFTC.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('DRAFTC',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and qe is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qe=ct then 1 else 0 end),5)||lpad(sum(case when ac=1 and qn is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from FINELINE.anaf_efactura_detalii dt join FINELINE.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('FINELINE',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and qe is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qe=ct then 1 else 0 end),5)||lpad(sum(case when ac=1 and qn is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from INTERIOR.anaf_efactura_detalii dt join INTERIOR.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('INTERIOR',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and qe is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qe=ct then 1 else 0 end),5)||lpad(sum(case when ac=1 and qn is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from PASS.anaf_efactura_detalii dt join PASS.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('PASS',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and qe is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qe=ct then 1 else 0 end),5)||lpad(sum(case when ac=1 and qn is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from CARAPETRU.anaf_efactura_detalii dt join CARAPETRU.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CARAPETRU',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and qe is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qe=ct then 1 else 0 end),5)||lpad(sum(case when ac=1 and qn is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from LEV.anaf_efactura_detalii dt join LEV.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('LEV',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and qe is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qe=ct then 1 else 0 end),5)||lpad(sum(case when ac=1 and qn is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from ANNA.anaf_efactura_detalii dt join ANNA.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('ANNA',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and qe is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qe=ct then 1 else 0 end),5)||lpad(sum(case when ac=1 and qn is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from CIAO.anaf_efactura_detalii dt join CIAO.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CIAO',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and qe is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qe=ct then 1 else 0 end),5)||lpad(sum(case when ac=1 and qn is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from CLINIDERMA.anaf_efactura_detalii dt join CLINIDERMA.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CLINIDERMA',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and qe is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qe=ct then 1 else 0 end),5)||lpad(sum(case when ac=1 and qn is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from DOMINUS.anaf_efactura_detalii dt join DOMINUS.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('DOMINUS',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and qe is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qe=ct then 1 else 0 end),5)||lpad(sum(case when ac=1 and qn is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from CUX.anaf_efactura_detalii dt join CUX.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CUX',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and qe is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qe=ct then 1 else 0 end),5)||lpad(sum(case when ac=1 and qn is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from CERAMOTERM.anaf_efactura_detalii dt join CERAMOTERM.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CERAMOTERM',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and qe is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qe=ct then 1 else 0 end),5)||lpad(sum(case when ac=1 and qn is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from DRAFTA.anaf_efactura_detalii dt join DRAFTA.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('DRAFTA',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and qe is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qe=ct then 1 else 0 end),5)||lpad(sum(case when ac=1 and qn is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from LEIL2.anaf_efactura_detalii dt join LEIL2.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('LEIL2',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and qe is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qe=ct then 1 else 0 end),5)||lpad(sum(case when ac=1 and qn is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from COTOFANACONCEPT.anaf_efactura_detalii dt join COTOFANACONCEPT.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('COTOFANACONCEPT',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and qe is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qe=ct then 1 else 0 end),5)||lpad(sum(case when ac=1 and qn is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from VIDD.anaf_efactura_detalii dt join VIDD.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('VIDD',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and qe is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qe=ct then 1 else 0 end),5)||lpad(sum(case when ac=1 and qn is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from DRAFTD.anaf_efactura_detalii dt join DRAFTD.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('DRAFTD',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and qe is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qe=ct then 1 else 0 end),5)||lpad(sum(case when ac=1 and qn is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn=ct then 1 else 0 end),5) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
upper(trim(dt.articol)) a_ex,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from CAPIDAVATOUR.anaf_efactura_detalii dt join CAPIDAVATOUR.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_ex order by d rows between unbounded preceding and 1 preceding) qe,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) qn
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CAPIDAVATOUR',14)||lpad(count(*),6)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and qe is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qe=ct then 1 else 0 end),5)||lpad(sum(case when ac=1 and qn is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and qn=ct then 1 else 0 end),5) from u;
exit

View File

@@ -0,0 +1,113 @@
set pagesize 0 linesize 220 feedback off heading off trimspool on
select 'FIRMA LINII CUCOD CUBARE CUNC8 DENCOD OKCOD' from dual;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(dt.codfurnizor) cf, trim(dt.codbare) cb, trim(dt.codnc8) c8,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from WERT.anaf_efactura_detalii dt join WERT.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')),
p as (select l.*, last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, cf order by d rows between unbounded preceding and 1 preceding) qc from l where cf is not null),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12)),
t as (select count(*) linii, sum(case when cf is not null then 1 else 0 end) cucod, sum(case when cb is not null then 1 else 0 end) cubare, sum(case when c8 is not null then 1 else 0 end) cunc8
from l where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('WERT',14)||lpad(t.linii,6)||lpad(t.cucod,6)||lpad(t.cubare,7)||lpad(t.cunc8,6)||lpad((select sum(case when ac=1 and qc is not null then 1 else 0 end) from u),7)||lpad((select sum(case when ac=1 and qc=ct then 1 else 0 end) from u),6) from t;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(dt.codfurnizor) cf, trim(dt.codbare) cb, trim(dt.codnc8) c8,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from DRAFTC.anaf_efactura_detalii dt join DRAFTC.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')),
p as (select l.*, last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, cf order by d rows between unbounded preceding and 1 preceding) qc from l where cf is not null),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12)),
t as (select count(*) linii, sum(case when cf is not null then 1 else 0 end) cucod, sum(case when cb is not null then 1 else 0 end) cubare, sum(case when c8 is not null then 1 else 0 end) cunc8
from l where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('DRAFTC',14)||lpad(t.linii,6)||lpad(t.cucod,6)||lpad(t.cubare,7)||lpad(t.cunc8,6)||lpad((select sum(case when ac=1 and qc is not null then 1 else 0 end) from u),7)||lpad((select sum(case when ac=1 and qc=ct then 1 else 0 end) from u),6) from t;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(dt.codfurnizor) cf, trim(dt.codbare) cb, trim(dt.codnc8) c8,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from FINELINE.anaf_efactura_detalii dt join FINELINE.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')),
p as (select l.*, last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, cf order by d rows between unbounded preceding and 1 preceding) qc from l where cf is not null),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12)),
t as (select count(*) linii, sum(case when cf is not null then 1 else 0 end) cucod, sum(case when cb is not null then 1 else 0 end) cubare, sum(case when c8 is not null then 1 else 0 end) cunc8
from l where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('FINELINE',14)||lpad(t.linii,6)||lpad(t.cucod,6)||lpad(t.cubare,7)||lpad(t.cunc8,6)||lpad((select sum(case when ac=1 and qc is not null then 1 else 0 end) from u),7)||lpad((select sum(case when ac=1 and qc=ct then 1 else 0 end) from u),6) from t;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(dt.codfurnizor) cf, trim(dt.codbare) cb, trim(dt.codnc8) c8,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from INTERIOR.anaf_efactura_detalii dt join INTERIOR.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')),
p as (select l.*, last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, cf order by d rows between unbounded preceding and 1 preceding) qc from l where cf is not null),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12)),
t as (select count(*) linii, sum(case when cf is not null then 1 else 0 end) cucod, sum(case when cb is not null then 1 else 0 end) cubare, sum(case when c8 is not null then 1 else 0 end) cunc8
from l where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('INTERIOR',14)||lpad(t.linii,6)||lpad(t.cucod,6)||lpad(t.cubare,7)||lpad(t.cunc8,6)||lpad((select sum(case when ac=1 and qc is not null then 1 else 0 end) from u),7)||lpad((select sum(case when ac=1 and qc=ct then 1 else 0 end) from u),6) from t;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(dt.codfurnizor) cf, trim(dt.codbare) cb, trim(dt.codnc8) c8,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from PASS.anaf_efactura_detalii dt join PASS.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')),
p as (select l.*, last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, cf order by d rows between unbounded preceding and 1 preceding) qc from l where cf is not null),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12)),
t as (select count(*) linii, sum(case when cf is not null then 1 else 0 end) cucod, sum(case when cb is not null then 1 else 0 end) cubare, sum(case when c8 is not null then 1 else 0 end) cunc8
from l where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('PASS',14)||lpad(t.linii,6)||lpad(t.cucod,6)||lpad(t.cubare,7)||lpad(t.cunc8,6)||lpad((select sum(case when ac=1 and qc is not null then 1 else 0 end) from u),7)||lpad((select sum(case when ac=1 and qc=ct then 1 else 0 end) from u),6) from t;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(dt.codfurnizor) cf, trim(dt.codbare) cb, trim(dt.codnc8) c8,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from CIAO.anaf_efactura_detalii dt join CIAO.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')),
p as (select l.*, last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, cf order by d rows between unbounded preceding and 1 preceding) qc from l where cf is not null),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12)),
t as (select count(*) linii, sum(case when cf is not null then 1 else 0 end) cucod, sum(case when cb is not null then 1 else 0 end) cubare, sum(case when c8 is not null then 1 else 0 end) cunc8
from l where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CIAO',14)||lpad(t.linii,6)||lpad(t.cucod,6)||lpad(t.cubare,7)||lpad(t.cunc8,6)||lpad((select sum(case when ac=1 and qc is not null then 1 else 0 end) from u),7)||lpad((select sum(case when ac=1 and qc=ct then 1 else 0 end) from u),6) from t;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(dt.codfurnizor) cf, trim(dt.codbare) cb, trim(dt.codnc8) c8,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from DOMINUS.anaf_efactura_detalii dt join DOMINUS.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')),
p as (select l.*, last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, cf order by d rows between unbounded preceding and 1 preceding) qc from l where cf is not null),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12)),
t as (select count(*) linii, sum(case when cf is not null then 1 else 0 end) cucod, sum(case when cb is not null then 1 else 0 end) cubare, sum(case when c8 is not null then 1 else 0 end) cunc8
from l where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('DOMINUS',14)||lpad(t.linii,6)||lpad(t.cucod,6)||lpad(t.cubare,7)||lpad(t.cunc8,6)||lpad((select sum(case when ac=1 and qc is not null then 1 else 0 end) from u),7)||lpad((select sum(case when ac=1 and qc=ct then 1 else 0 end) from u),6) from t;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(dt.codfurnizor) cf, trim(dt.codbare) cb, trim(dt.codnc8) c8,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from VIDD.anaf_efactura_detalii dt join VIDD.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')),
p as (select l.*, last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, cf order by d rows between unbounded preceding and 1 preceding) qc from l where cf is not null),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12)),
t as (select count(*) linii, sum(case when cf is not null then 1 else 0 end) cucod, sum(case when cb is not null then 1 else 0 end) cubare, sum(case when c8 is not null then 1 else 0 end) cunc8
from l where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('VIDD',14)||lpad(t.linii,6)||lpad(t.cucod,6)||lpad(t.cubare,7)||lpad(t.cunc8,6)||lpad((select sum(case when ac=1 and qc is not null then 1 else 0 end) from u),7)||lpad((select sum(case when ac=1 and qc=ct then 1 else 0 end) from u),6) from t;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(dt.codfurnizor) cf, trim(dt.codbare) cb, trim(dt.codnc8) c8,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from CERAMOTERM.anaf_efactura_detalii dt join CERAMOTERM.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')),
p as (select l.*, last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, cf order by d rows between unbounded preceding and 1 preceding) qc from l where cf is not null),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12)),
t as (select count(*) linii, sum(case when cf is not null then 1 else 0 end) cucod, sum(case when cb is not null then 1 else 0 end) cubare, sum(case when c8 is not null then 1 else 0 end) cunc8
from l where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CERAMOTERM',14)||lpad(t.linii,6)||lpad(t.cucod,6)||lpad(t.cubare,7)||lpad(t.cunc8,6)||lpad((select sum(case when ac=1 and qc is not null then 1 else 0 end) from u),7)||lpad((select sum(case when ac=1 and qc=ct then 1 else 0 end) from u),6) from t;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(dt.codfurnizor) cf, trim(dt.codbare) cb, trim(dt.codnc8) c8,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from LEIL2.anaf_efactura_detalii dt join LEIL2.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')),
p as (select l.*, last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, cf order by d rows between unbounded preceding and 1 preceding) qc from l where cf is not null),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12)),
t as (select count(*) linii, sum(case when cf is not null then 1 else 0 end) cucod, sum(case when cb is not null then 1 else 0 end) cubare, sum(case when c8 is not null then 1 else 0 end) cunc8
from l where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('LEIL2',14)||lpad(t.linii,6)||lpad(t.cucod,6)||lpad(t.cubare,7)||lpad(t.cunc8,6)||lpad((select sum(case when ac=1 and qc is not null then 1 else 0 end) from u),7)||lpad((select sum(case when ac=1 and qc=ct then 1 else 0 end) from u),6) from t;
exit

View File

@@ -0,0 +1,255 @@
set pagesize 0 linesize 220 feedback off heading off trimspool on
select 'FIRMA CUCONT D_FULL OK_FULL D_P25 OK_P25 D_P12 OK_P12' from dual;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from WERT.anaf_efactura_detalii dt join WERT.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) q1,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,25) order by d rows between unbounded preceding and 1 preceding) q2,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,12) order by d rows between unbounded preceding and 1 preceding) q3
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('WERT',13)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and q1 is not null then 1 else 0 end),7)||lpad(sum(case when ac=1 and q1=ct then 1 else 0 end),8)||lpad(sum(case when ac=1 and q2 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q2=ct then 1 else 0 end),7)||lpad(sum(case when ac=1 and q3 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q3=ct then 1 else 0 end),7) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from DRAFTC.anaf_efactura_detalii dt join DRAFTC.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) q1,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,25) order by d rows between unbounded preceding and 1 preceding) q2,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,12) order by d rows between unbounded preceding and 1 preceding) q3
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('DRAFTC',13)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and q1 is not null then 1 else 0 end),7)||lpad(sum(case when ac=1 and q1=ct then 1 else 0 end),8)||lpad(sum(case when ac=1 and q2 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q2=ct then 1 else 0 end),7)||lpad(sum(case when ac=1 and q3 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q3=ct then 1 else 0 end),7) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from FINELINE.anaf_efactura_detalii dt join FINELINE.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) q1,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,25) order by d rows between unbounded preceding and 1 preceding) q2,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,12) order by d rows between unbounded preceding and 1 preceding) q3
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('FINELINE',13)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and q1 is not null then 1 else 0 end),7)||lpad(sum(case when ac=1 and q1=ct then 1 else 0 end),8)||lpad(sum(case when ac=1 and q2 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q2=ct then 1 else 0 end),7)||lpad(sum(case when ac=1 and q3 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q3=ct then 1 else 0 end),7) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from INTERIOR.anaf_efactura_detalii dt join INTERIOR.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) q1,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,25) order by d rows between unbounded preceding and 1 preceding) q2,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,12) order by d rows between unbounded preceding and 1 preceding) q3
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('INTERIOR',13)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and q1 is not null then 1 else 0 end),7)||lpad(sum(case when ac=1 and q1=ct then 1 else 0 end),8)||lpad(sum(case when ac=1 and q2 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q2=ct then 1 else 0 end),7)||lpad(sum(case when ac=1 and q3 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q3=ct then 1 else 0 end),7) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from PASS.anaf_efactura_detalii dt join PASS.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) q1,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,25) order by d rows between unbounded preceding and 1 preceding) q2,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,12) order by d rows between unbounded preceding and 1 preceding) q3
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('PASS',13)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and q1 is not null then 1 else 0 end),7)||lpad(sum(case when ac=1 and q1=ct then 1 else 0 end),8)||lpad(sum(case when ac=1 and q2 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q2=ct then 1 else 0 end),7)||lpad(sum(case when ac=1 and q3 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q3=ct then 1 else 0 end),7) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from CARAPETRU.anaf_efactura_detalii dt join CARAPETRU.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) q1,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,25) order by d rows between unbounded preceding and 1 preceding) q2,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,12) order by d rows between unbounded preceding and 1 preceding) q3
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CARAPETRU',13)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and q1 is not null then 1 else 0 end),7)||lpad(sum(case when ac=1 and q1=ct then 1 else 0 end),8)||lpad(sum(case when ac=1 and q2 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q2=ct then 1 else 0 end),7)||lpad(sum(case when ac=1 and q3 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q3=ct then 1 else 0 end),7) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from LEV.anaf_efactura_detalii dt join LEV.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) q1,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,25) order by d rows between unbounded preceding and 1 preceding) q2,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,12) order by d rows between unbounded preceding and 1 preceding) q3
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('LEV',13)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and q1 is not null then 1 else 0 end),7)||lpad(sum(case when ac=1 and q1=ct then 1 else 0 end),8)||lpad(sum(case when ac=1 and q2 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q2=ct then 1 else 0 end),7)||lpad(sum(case when ac=1 and q3 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q3=ct then 1 else 0 end),7) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from ANNA.anaf_efactura_detalii dt join ANNA.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) q1,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,25) order by d rows between unbounded preceding and 1 preceding) q2,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,12) order by d rows between unbounded preceding and 1 preceding) q3
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('ANNA',13)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and q1 is not null then 1 else 0 end),7)||lpad(sum(case when ac=1 and q1=ct then 1 else 0 end),8)||lpad(sum(case when ac=1 and q2 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q2=ct then 1 else 0 end),7)||lpad(sum(case when ac=1 and q3 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q3=ct then 1 else 0 end),7) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from CIAO.anaf_efactura_detalii dt join CIAO.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) q1,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,25) order by d rows between unbounded preceding and 1 preceding) q2,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,12) order by d rows between unbounded preceding and 1 preceding) q3
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CIAO',13)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and q1 is not null then 1 else 0 end),7)||lpad(sum(case when ac=1 and q1=ct then 1 else 0 end),8)||lpad(sum(case when ac=1 and q2 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q2=ct then 1 else 0 end),7)||lpad(sum(case when ac=1 and q3 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q3=ct then 1 else 0 end),7) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from CLINIDERMA.anaf_efactura_detalii dt join CLINIDERMA.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) q1,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,25) order by d rows between unbounded preceding and 1 preceding) q2,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,12) order by d rows between unbounded preceding and 1 preceding) q3
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CLINIDERMA',13)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and q1 is not null then 1 else 0 end),7)||lpad(sum(case when ac=1 and q1=ct then 1 else 0 end),8)||lpad(sum(case when ac=1 and q2 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q2=ct then 1 else 0 end),7)||lpad(sum(case when ac=1 and q3 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q3=ct then 1 else 0 end),7) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from DOMINUS.anaf_efactura_detalii dt join DOMINUS.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) q1,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,25) order by d rows between unbounded preceding and 1 preceding) q2,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,12) order by d rows between unbounded preceding and 1 preceding) q3
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('DOMINUS',13)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and q1 is not null then 1 else 0 end),7)||lpad(sum(case when ac=1 and q1=ct then 1 else 0 end),8)||lpad(sum(case when ac=1 and q2 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q2=ct then 1 else 0 end),7)||lpad(sum(case when ac=1 and q3 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q3=ct then 1 else 0 end),7) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from CUX.anaf_efactura_detalii dt join CUX.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) q1,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,25) order by d rows between unbounded preceding and 1 preceding) q2,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,12) order by d rows between unbounded preceding and 1 preceding) q3
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CUX',13)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and q1 is not null then 1 else 0 end),7)||lpad(sum(case when ac=1 and q1=ct then 1 else 0 end),8)||lpad(sum(case when ac=1 and q2 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q2=ct then 1 else 0 end),7)||lpad(sum(case when ac=1 and q3 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q3=ct then 1 else 0 end),7) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from CERAMOTERM.anaf_efactura_detalii dt join CERAMOTERM.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) q1,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,25) order by d rows between unbounded preceding and 1 preceding) q2,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,12) order by d rows between unbounded preceding and 1 preceding) q3
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CERAMOTERM',13)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and q1 is not null then 1 else 0 end),7)||lpad(sum(case when ac=1 and q1=ct then 1 else 0 end),8)||lpad(sum(case when ac=1 and q2 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q2=ct then 1 else 0 end),7)||lpad(sum(case when ac=1 and q3 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q3=ct then 1 else 0 end),7) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from DRAFTA.anaf_efactura_detalii dt join DRAFTA.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) q1,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,25) order by d rows between unbounded preceding and 1 preceding) q2,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,12) order by d rows between unbounded preceding and 1 preceding) q3
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('DRAFTA',13)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and q1 is not null then 1 else 0 end),7)||lpad(sum(case when ac=1 and q1=ct then 1 else 0 end),8)||lpad(sum(case when ac=1 and q2 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q2=ct then 1 else 0 end),7)||lpad(sum(case when ac=1 and q3 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q3=ct then 1 else 0 end),7) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from LEIL2.anaf_efactura_detalii dt join LEIL2.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) q1,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,25) order by d rows between unbounded preceding and 1 preceding) q2,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,12) order by d rows between unbounded preceding and 1 preceding) q3
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('LEIL2',13)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and q1 is not null then 1 else 0 end),7)||lpad(sum(case when ac=1 and q1=ct then 1 else 0 end),8)||lpad(sum(case when ac=1 and q2 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q2=ct then 1 else 0 end),7)||lpad(sum(case when ac=1 and q3 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q3=ct then 1 else 0 end),7) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from COTOFANACONCEPT.anaf_efactura_detalii dt join COTOFANACONCEPT.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) q1,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,25) order by d rows between unbounded preceding and 1 preceding) q2,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,12) order by d rows between unbounded preceding and 1 preceding) q3
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('COTOFANACONCEPT',13)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and q1 is not null then 1 else 0 end),7)||lpad(sum(case when ac=1 and q1=ct then 1 else 0 end),8)||lpad(sum(case when ac=1 and q2 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q2=ct then 1 else 0 end),7)||lpad(sum(case when ac=1 and q3 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q3=ct then 1 else 0 end),7) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from VIDD.anaf_efactura_detalii dt join VIDD.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) q1,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,25) order by d rows between unbounded preceding and 1 preceding) q2,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,12) order by d rows between unbounded preceding and 1 preceding) q3
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('VIDD',13)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and q1 is not null then 1 else 0 end),7)||lpad(sum(case when ac=1 and q1=ct then 1 else 0 end),8)||lpad(sum(case when ac=1 and q2 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q2=ct then 1 else 0 end),7)||lpad(sum(case when ac=1 and q3 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q3=ct then 1 else 0 end),7) from u;
with l as (select e.cod_fiscal_emitent cui, e.xdata_act d,
trim(regexp_replace(regexp_replace(regexp_replace(upper(dt.articol),'[0-9]+',' '),'[^A-Z ]',' '),' +',' ')) a_no,
case when dt.cont is not null and trim(dt.cont) is not null then 1 else 0 end ac,
trim(dt.cont)||'.'||trim(nvl(dt.acont,' ')) ct
from CAPIDAVATOUR.anaf_efactura_detalii dt join CAPIDAVATOUR.anaf_efactura e on e.id = dt.id_efactura
where nvl(e.factura_emisa,0)=0 and e.xdata_act >= add_months(trunc(sysdate,'MM'),-24) and e.xdata_act < trunc(sysdate,'MM')
and dt.articol is not null),
p as (select l.*,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, a_no order by d rows between unbounded preceding and 1 preceding) q1,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,25) order by d rows between unbounded preceding and 1 preceding) q2,
last_value(case when ac=1 then ct end) ignore nulls over (partition by cui, substr(a_no,1,12) order by d rows between unbounded preceding and 1 preceding) q3
from l),
u as (select * from p where d >= add_months(trunc(sysdate,'MM'),-12))
select rpad('CAPIDAVATOUR',13)||lpad(sum(ac),6)||lpad(sum(case when ac=1 and q1 is not null then 1 else 0 end),7)||lpad(sum(case when ac=1 and q1=ct then 1 else 0 end),8)||lpad(sum(case when ac=1 and q2 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q2=ct then 1 else 0 end),7)||lpad(sum(case when ac=1 and q3 is not null then 1 else 0 end),6)||lpad(sum(case when ac=1 and q3=ct then 1 else 0 end),7) from u;
exit