lundi 16 juillet 2018

Cannot access aliased column in the having clause in the query builder, laravel 5.0

In select statement

->select(DB::Raw('IFNULL(upm2.meta_value,(CASE WHEN UserSubscription.subscription_plan = "MASHVISOR_PRO_AGENT" THEN 2 WHEN UserSubscription.subscription_plan = "MASHVISOR_EXPERT_AGENT" THEN 3 WHEN UserSubscription.subscription_plan = "MASHVISOR_TOP_AGENT" THEN 4 ELSE upm2.meta_value END)) - COUNT(distinct AL1.id) AS remainingLeads')) and in having statement ->having(DB::raw('remainingLeads'), $comp , $remainingLeads ? $remainingLeads : -9999 ))

IN HAVING

 ->having(DB::raw('`remainingLeads`'),  $comp , $remainingLeads ? $remainingLeads : -9999 )



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire