mysql select condition with 3 conditions -
i have table have field called cheque_type , filed comes 3 variables such life,nonmotor,motor
and table has time stamp. need result how many life, nonmotor , motors checks printed
what need add 3 columns sql query , number of results according category
select date(`timestamp`) ___date___, count(`id`) total, sum(print_status) printed, (count(`id`) - sum(print_status)) to_be_print cheque.vouchers date( `timestamp`) >='2014-11-15' , date( `timestamp`) <='2014-11-31' group date(`timestamp`) ;
select date(`timestamp`) ___date___, count(`id`) total, sum(print_status) printed, (count(`id`) - sum(print_status)) to_be_print, sum(cheque_type = 'life') life_check, sum(cheque_type = 'nonmotor') non_check, sum(cheque_type = 'motor') motor_check cheque.vouchers date( `timestamp`) >='2014-11-15' , date( `timestamp`) <='2014-11-31' group date(`timestamp`) ;
Comments
Post a Comment