select
CI.C07_special_code,
count(distinct ci.isr_no)
from c07_special_table ci, isr i
where i.isr_no = ci.isr_no
--and ci.C07_START_DATETIME BETWEEN '16-MAR-22 02.00.00.000000000 PM UTC' AND '16-MAR-22 04.15.00.000000000 PM UTC'
and ci.C07_START_DATETIME >= '16-MAR-22 02.00.00.000000000 PM UTC'
and ci.C07_START_DATETIME <= '16-MAR-22 04.15.00.000000000 PM UTC'
and i.isr_no like 'PECO%'
group by CI.C07_special_code
select CI.C07_special_code, count(distinct ci.isr_no) 
from c07_special_table ci, isr i 
where i.isr_no = ci.isr_no 
and ci.C07_START_DATETIME BETWEEN '16-MAR-22 02.00.00.000000000 PM UTC' 
AND '16-MAR-22 04.15.00.000000000 PM UTC' 
and ci.C07_START_DATETIME >= '16-MAR-22 02.00.00.000000000 PM UTC' 
and ci.C07_START_DATETIME <= '16-MAR-22 04.15.00.000000000 PM UTC' 
and i.isr_no like 'PECO%' group by CI.C07_special_code
 column NAME_OF_THE_COLUMN format A30
select external_no1, s_mode, p_origin
define monthly_value = 0
define daily_value = 10

LOOP
monthly_value := daily_value * 31;

select * from table fetch first 1 row only;


EXIT WHEN monthly_value > 4000;
END LOOP
GoBack