Mysql criteria in where clause not reporting properly -


i have following mysql query working apart sum part. result getting sum_io , sum_nio being calculated on whole table if criteria part

cast(oee_main_interim.ts date) = curdate()

is being ignored. want query sum values fall under today's date (curdate()):

select   oee_main_interim.name machine_id,   oee_machinenames.name name,   voee_mach_shifts.curr_shift curr_shift,   sum((oee_main_interim.left_io + oee_main_interim.right_io)) sum_io,   sum((oee_main_interim.left_nio + oee_main_interim.right_nio)) sum_nio   (oee_main_interim join   voee_mach_shifts on voee_mach_shifts.id = oee_main_interim.name) join   oee_machinenames on oee_machinenames.id = oee_main_interim.name   cast(oee_main_interim.ts date) = curdate() ,   oee_main_interim.shift in (select     voee_mach_shifts.curr_shift       voee_mach_shifts join     oee_machinenames on oee_machinenames.id = voee_mach_shifts.id   group     voee_mach_shifts.curr_shift, oee_machinenames.id   order     oee_machinenames.id) group   oee_main_interim.name, oee_machinenames.name, voee_mach_shifts.curr_shift order   oee_system.oee_main_interim.name 

you can use date(yourfield)=curdate() match date part of timestamp or datetime field.


Comments