-1
我有3個表格:航空公司,航班,信息。laravel複雜sql查詢
- 每個航空公司「有很多」的航班。
- 每個航班「有很多」的信息。
- 每家航空公司「有很多通」的信息。
我需要查詢的查詢DB或雄辯ORM得到這樣的信息:
---------------------------------------------------------------
id | airline_name | infos_count | infos_canceled | infos_late
---------------------------------------------------------------
1 b_airline 6 2 5(minutes)
airline_name: name of airline company
infos_count: count of info which belong to flight table and this airline company
infos_canceled: count of info where (status=0)
infos_canceled: sum of (subtract time of schedule_time)
我這樣做是使用變壓器類,但我想這個使用查詢.. 任何幫助,請。 。
感謝您的回答。(ID,airlinename,infos_count)由加載工作 「GROUP BY A.id」,但取消和延遲不工作 –
什麼領域確定何時取消或遲到狀態? – Jake