mercredi 2 septembre 2015

How to convert the below query in query builder laravel

I have the below query in general format. I want to convert this query using query builder method. Some one help

Select count(`count`) count,`status` 
    from (select count(`id_student`) count, 
     CASE 
      WHEN (date_format(max(`expiry_date`),'%Y-%m-%d') < CURDATE()) THEN 'Subscription Expired' 
      WHEN (date_format(max(`expiry_date`),'%Y-%m-%d') >= CURDATE() && sum(`completed_test_count`) = sum(`total_test_count`) ) THEN 'Test Completed' 
      WHEN (date_format(max(`expiry_date`),'%Y-%m-%d') >= CURDATE() && sum(`completed_test_count`) < sum(`total_test_count`) ) THEN 'Active' 
      END status 
    from `order` 
    inner join `student` on `id_student` = `order`.`student_id_student` 
    inner join `order_has_test` on `order_id_order` = `order`.`id_order` 
    inner join `subscription_plan` on `id_subscription_plan` =    `subscription_plan_id_subscription_plan` 
    where `subscription_plan_id_subscription_plan` = 1
    group by `order`.`student_id_student`) data
 group by `status` 



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Utv2tw
via IFTTT

Aucun commentaire:

Enregistrer un commentaire