mardi 30 mai 2017

Group by not working - Laravel 5.2

Group by is not working, may be because i am using mathematical expression in the select option. Kindly help.

select FLOOR(SUM(DATEDIFF(rd.checkin_date,rd.created_at))/COUNT(DATEDIFF(rd.checkin_date,rd.created_at))) AS names, 

COUNT(rd.id) as totbooking, SUM(DATEDIFF(rd.checkout_date,rd.checkin_date)) AS nights, round(SUM(CASE WHEN h.currency_id=151 THEN rd.total_cents WHEN h.currency_id!=151 THEN rd.total_cents/cur.exchange_rate ELSE 0 END)/100) AS revenue, round((round(SUM(CASE WHEN h.currency_id=151 THEN rd.total_cents WHEN h.currency_id!=151 THEN rd.total_cents/cur.exchange_rate ELSE 0 END)/100)) / (SUM(DATEDIFF(rd.checkout_date,rd.checkin_date)))) as adr, FLOOR((FLOOR(SUM(CASE WHEN h.currency_id=151 THEN rd.total_cents WHEN h.currency_id!=151 THEN rd.total_cents/cur.exchange_rate ELSE 0 END)/100)) / COUNT(rd.id)) as atp, FLOOR(SUM(DATEDIFF(rd.checkin_date,rd.created_at))/COUNT(DATEDIFF(rd.checkin_date,rd.created_at))) as leadtime, SUM(DATEDIFF(rd.checkout_date,rd.checkin_date)) / (COUNT(rd.id)) as alos, (SUM(DATEDIFF(rd.checkout_date,rd.checkin_date)) / (h.total_rooms * 31))*100 as share

from reservation_details as rd left join hotels as h on rd.hotel_id = h.id left join currencies as cur on cur.id = h.currency_id left join chains as c on c.id = h.chain_id where rd.status >= 50 and date(rd.created_at) >= "2017-04-30" and date(rd.created_at) <= "2017-05-30" GROUP BY names



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire