Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- within 1 month
- select count(*) from (select rl1.* from phy_req_list rl1 left join phy_req_list rl2
- on (rl1.doc_type = rl2.doc_type and rl1.id = rl2.id and rl1.updated_date < rl2.updated_date)
- where rl2.updated_date is null) as rl_filtered_latest_udpated_date_per_id_doc_type
- where doc_type = 'PRC_ID' and validity_date > CURDATE() and validity_date <= DATE_ADD(CURDATE(), INTERVAL 1 MONTH);
- -- within 3 months
- select count(*) from (select rl1.* from phy_req_list rl1 left join phy_req_list rl2
- on (rl1.doc_type = rl2.doc_type and rl1.id = rl2.id and rl1.updated_date < rl2.updated_date)
- where rl2.updated_date is null) as rl_filtered_latest_udpated_date_per_id_doc_type
- where doc_type = 'PRC_ID' and validity_date > DATE_ADD(CURDATE(), INTERVAL 1 MONTH) and validity_date <= DATE_ADD(CURDATE(), INTERVAL 3 MONTH);
- -- expired
- select count(*) from (select rl1.* from phy_req_list rl1 left join phy_req_list rl2
- on (rl1.doc_type = rl2.doc_type and rl1.id = rl2.id and rl1.updated_date < rl2.updated_date)
- where rl2.updated_date is null) as rl_filtered_latest_udpated_date_per_id_doc_type
- where doc_type = 'PRC_ID' and validity_date <= CURDATE();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement