mysql - SQL query to do division -
please on below sql query divide first set of query second one.
select ( select `business_unit`, count(`joining_month`) `jl` `final_status` = 'joined' , `source_wise` = 'referral' , `hiring_catg` in ('lateral','contract conversion') group `business_unit` ) div ( select `business_unit`, count(`joining_month`) b `jl` `final_status` = 'joined' , `hiring_catg` in ('lateral','contract conversion') group `business_unit` ) ;
the query posted dead-end; cannot made work in direction.
i try count number of rows pass condition source_wise = 'referral'
, total number of rows each group , compute ratio.
the query this:
select `business_unit`, sum(if(`source_wise` = 'referral', 1, 0)) ref count(`joining_month`) total `jl` `final_status` = 'joined' , `hiring_catg` in ('lateral','contract conversion') group `business_unit`
you have compute ref/total
each row in client code. or can compute directly changing query above.
Comments
Post a Comment