sql - How to fetch records between a given date range and both date range should include for searching records? -
here query:
select decode(avsr.informationtype,'null','unknown','5','infectious agent transmission issue','4','environmental issue','3','withdrawal period issue','2','lack of expected efficacy','1','safety issue') infotype, count(vm.vaer_no), avsr.informationtype agvet_vae_info vm, agvet_vae_safetyreport avsr avsr.record_id = vm.fk_avsr_rec_id , vm.vaer_delete = 0 , vm.archived = 0 , vm.e2b_message_list_type <> 01 , vm.import_flag <> 1 , avsr.originalreceivedate between to_date ('2000/04/1', 'yyyy/mm/dd') , to_date ('2000/04/28', 'yyyy/mm/dd')+1 group avsr.informationtype in query displaying records 2000/04/29 also.but need records 2000/04/1 2000/04/28 (inclusive both dates).
1) using trunc
and trunc(avsr.originalreceivedate) between to_date ('2000/04/1', 'yyyy/mm/dd') , to_date ('2000/04/28', 'yyyy/mm/dd') but ignore if index there on column avsr.originalreceivedate, use if there no index on column or if there functional index using function trunc
2) using >= , <
and (avsr.originalreceivedate >= to_date ('2000/04/1', 'yyyy/mm/dd') , avsr.originalreceivedate < (to_date ('2000/04/28', 'yyyy/mm/dd') + 1)) 3) using timestamp
and avsr.originalreceivedate between to_date ('2000/04/1 00:00:00', 'yyyy/mm/dd hh24:mi:ss') , to_date ('2000/04/28 23:59:59', 'yyyy/mm/dd hh24:mi:ss')
Comments
Post a Comment