zOs/TX/PA2DISEL

select d.* from
     qz92crT.tqz91pa2diPart p join qz92crT.tqz91pa2diData d
       on p.p = d.p and d.cif >= p.cifBeg and d.cif < p.cifEnd
                    and d.aDt >= p.aDtBeg and d.aDt < p.aDtEnd
       where d.cif = 'C_PG'
           and d.aDt  = '25.04.2016'
;
select d.* from
     qz92crT.tqz91pa2diPart p join qz92crT.tqz91pa2diData d
       on p.p = d.p and d.cif >= p.cifBeg and d.cif < p.cifEnd
                    and d.aDt >= p.aDtBeg and d.aDt < p.aDtEnd
       where d.cif  = 'C_PG'
           and d.aDt >= '25.04.2016' and d.aDt < '04.05.2016'
;
select count(*)
     from qz92crT.tqz91pa2diPart p join qz92crT.tqz91pa2diData d
       on p.p = d.p and d.cif >= p.cifBeg and d.cif < p.cifEnd
                    and d.aDt >= p.aDtBeg and d.aDt < p.aDtEnd
       where d.cif  >= 'CS' and d.cif < 'DB'
           and d.aDt >= '25.04.2016' and d.aDt < '04.05.2016'
;
select count(*)
     from qz92crT.tqz91pa2diPart p join qz92crT.tqz91pa2diData d
       on p.p = d.p and d.cif >= p.cifBeg and d.cif < p.cifEnd
                    and d.aDt >= p.aDtBeg and d.aDt < p.aDtEnd
       where d.cif  >= 'CS' and d.cif < 'DB'
           and d.aDt >= '25.04.2016' and d.aDt < '04.05.2016'
           and p.cifEnd > 'CS' and p.cifBeg < 'DB'
           and p.aDtEnd > '25.04.2016' and p.aDtBeg < '04.05.2016'
;x;
select p, count(*)
    from qz92crT.tqz91pa2diPart p
       where p.cifEnd  > 'BB' and p.cifBeg < 'DD'
           and p.aDtEnd > '05.02.2016' and p.aDtBeg < '05.04.2016'
    group by p
    order by p
;
select p, count(*)
    from qz92crT.tqz91pa2diData d
       where d.cif  >= 'BB' and d.cif < 'DD'
           and d.aDt >= '05.02.2016' and d.aDt < '05.04.2016'
    group by p
    order by p
;
select d.p, count(*)
    from qz92crT.tqz91pa2diPart p join qz92crT.tqz91pa2diData d
    on p.p = d.p
       where p.cifEnd  > 'BB' and p.cifBeg < 'DD'
           and p.aDtEnd > '05.02.2016' and p.aDtBeg < '05.04.2016'
           and d.cif  >= 'BB' and d.cif < 'DD'
           and d.aDt >= '05.02.2016' and d.aDt < '05.04.2016'
    group by d.p
    order by d.p
; x;x;