SCDF Count Sql
SELECT DISTINCT (SELECT COUNT (1)
FROM tbl_ndr_tra_reg a
WHERE a.form_type = 'SCDF'
AND a.delete_ind = 'N'
AND a.SCDF_INCIDENT_DT BETWEEN TO_DATE ('#edFromDate#',
'dd/MM/yyyy'
)
AND TO_DATE ('#edtoDate#',
'dd/MM/yyyy'
)) scdfnotconvey,
(SELECT COUNT (1)
FROM tbl_ndr_tra_reg a,
tbl_ndr_tra_raw_scdf b,
tbl_ndr_tra_link c
WHERE a.delete_ind = 'N'
AND b.delete_ind = 'N'
AND c.delete_ind = 'N'
AND a.rec_no = c.rec1
AND b.rec_no = c.rec2
AND a.scdf_incident_no = b.scdf_incident_no
AND a.scdf_call_sign_no = b.scdf_call_sign_no
AND a.scdf_info_st = 'Y'
AND b.linking_st = 'L'
AND a.form_type = 'ITS'
AND a.SCDF_INCIDENT_DT BETWEEN TO_DATE ('#edFromDate#',
'dd/MM/yyyy'
)
AND TO_DATE ('#edtoDate#',
'dd/MM/yyyy'
)) scdflinked,
(SELECT COUNT (1)
FROM tbl_ndr_tra_raw_scdf a
WHERE a.delete_ind = 'N'
AND a.linking_st IN ('O', 'S', 'D', 'X')
AND a.SCDF_INCIDENT_DT BETWEEN TO_DATE ('#edFromDate#',
'dd/MM/yyyy'
)
AND TO_DATE ('#edtoDate#',
'dd/MM/yyyy'
)) osdx,
(SELECT COUNT (1)
FROM (SELECT DISTINCT a.exception_no
FROM tbl_ndr_tra_exception a,
tbl_ndr_tra_follow_up b,
tbl_ndr_tra_raw_scdf c
WHERE a.exception_no = b.follow_up_rec_no
AND a.exception_type LIKE ('SCDF_ERR%')
AND b.follow_up_status IN ('P', 'A')
AND a.rec_no2 = c.rec_no
AND a.delete_ind = 'N'
AND b.delete_ind = 'N'
AND c.delete_ind = 'N'
AND c.SCDF_INCIDENT_DT BETWEEN TO_DATE ('#edFromDate#',
'dd/MM/yyyy'
)
AND TO_DATE ('#edtoDate#',
'dd/MM/yyyy'
)))
scdfexceptions
FROM tbl_ndr_tra_reg
BID COUNT SQL
SELECT DISTINCT ( (SELECT COUNT (1)
FROM tbl_ndr_tra_reg a
WHERE a.form_type = 'BID'
AND a.reg_no is not null
AND a.delete_ind = 'N'
AND a.bid_online_add_st = 'Y'
AND a.hsa_death_dt >= TO_DATE ('#edFromDate#', 'dd/MM/yyyy')
AND a.hsa_death_dt <= TO_DATE ('#edtoDate#', 'dd/MM/yyyy')
)
+ (SELECT COUNT (1)
FROM tbl_ndr_tra_reg a, tbl_ndr_tra_raw_bid b
WHERE a.form_type = 'BID'
AND a.delete_ind = 'N'
AND b.delete_ind = 'N'
AND a.reg_no is not null
AND b.linking_st Not IN ('D', 'X')
AND a.hsa_bid_id = b.hsa_bid_case_id
AND b.linking_st = 'C'
AND a.bid_online_add_st IS NULL
AND a.hsa_death_dt >= TO_DATE ('#edFromDate#', 'dd/MM/yyyy')
AND a.hsa_death_dt <= TO_DATE ('#edtoDate#', 'dd/MM/yyyy')
)
) stand_alone_count,
(SELECT COUNT (1)
FROM tbl_ndr_tra_reg a,
tbl_ndr_tra_raw_bid b,
tbl_ndr_tra_link c
WHERE a.delete_ind = 'N'
AND b.delete_ind = 'N'
AND c.delete_ind = 'N'
AND a.hsa_bid_id = b.hsa_bid_case_id
AND a.hsa_bid_info = 'Y'
AND b.linking_st = 'L'
AND a.form_type = 'ITS'
AND a.rec_no = c.rec1
AND b.rec_no = c.rec2
AND a.hsa_death_dt >= TO_DATE ('#edFromDate#', 'dd/MM/yyyy')
AND a.hsa_death_dt <= TO_DATE ('#edtoDate#', 'dd/MM/yyyy')
) link_ntr_count,
(SELECT COUNT (1)
FROM tbl_ndr_tra_raw_bid a
WHERE a.delete_ind = 'N'
AND a.linking_st IN ('D', 'X')
AND a.hsa_death_dt >= TO_DATE ('#edFromDate#', 'dd/MM/yyyy')
AND a.hsa_death_dt <= TO_DATE ('#edtoDate#', 'dd/MM/yyyy')
) draft_count,
(SELECT COUNT (1)
FROM (SELECT DISTINCT a.exception_no
FROM tbl_ndr_tra_exception a,
tbl_ndr_tra_follow_up b,
tbl_ndr_tra_raw_bid c
WHERE a.exception_no = b.follow_up_rec_no
AND a.exception_type LIKE ('BID_ERR%')
AND b.follow_up_status IN ('P', 'A')
AND a.rec_no2 = c.rec_no
AND c.delete_ind = 'N'
AND a.delete_ind = 'N'
AND b.delete_ind = 'N'
AND c.hsa_death_dt >= TO_DATE ('#edFromDate#', 'dd/MM/yyyy')
AND c.hsa_death_dt <= TO_DATE ('#edtoDate#', 'dd/MM/yyyy')
)) exception_count
FROM tbl_ndr_tra_link