lundi 27 mars 2017

how to use multiple table in laravel?

i have this query which i need to use in laravel. I don't how can i use these tables in model and controller.

select  mon,year,
        combo,
       registered,
       forwardedbycmo,
       clarification,
       noaction,
       disposed,mon_srno,undertaken
from monthly_activities
union
select extract('month' from actiondate) as mon,extract('year' from actiondate) as year,
        extract('year' from actiondate)|| '-' ||to_char(to_timestamp (extract('month' from actiondate)::text, 'MM'), 'TMMon') as combo,
       sum(case when actioncode = '00' then 1 else 0 end) as registered,
       sum(case when actioncode = '4T' and fromorg='CMOFF' then 1 else 0 end) as forwardedbycmo,
       sum(case when actioncode = '4D' and fromorg='CMOFF' then 1 else 0 end) as clarification,
       sum(case when actioncode = '10' then 1 else 0 end) as noaction,
       sum(case when actioncode = '50' then 1 else 0 end) as disposed,null as mon_srno,
        sum(case when actioncode = '40' and fromorg='CMOFF' then 1 else 0 end) as undertaken

from actionhistory where extract(month from actiondate)=extract(month from current_date)
and extract(year from actiondate)=extract(year from current_date)
 group by mon,year order by year,mon;
";



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

Aucun commentaire:

Enregistrer un commentaire