我在3个表中使用JOIN
并获取计数。
cab_allocation
我正在使用Total_Count和escort_allocation
我正在使用Escort_Count,例如 trip_details allocationId我正在使用forien key escort_allocation使用内连接我正在计算。 Adhoc_Trip_Count 我从trip_details
和cab_allocation
开始。 trip_details allocationId我正在使用forien key cab_allocation 使用这个我正在计算,我的查询工作正常。 现在我的问题是我想在两个日期添加BETWEEN 。在trip_details表中我有一个名为tripDate
的列。假设我给的日期如2018-03-20
INTO 2018-03-23
表示我希望在这两个日期之间获取记录
MYSQL QUERY
SELECT COUNT(T.tripId) as Escort_Count,
(
SELECT COUNT(*) FROM
(
SELECT a.allocationId
FROM escort_allocation a
INNER JOIN cab_allocation c ON a.allocationId = c.allocationId
WHERE c.allocationType = 'Adhoc Trip'
GROUP BY a.allocationId
) AS Ad
) AS Adhoc_Trip_Count,
(SELECT COUNT(id) FROM trip_details) as Total_Count
FROM
(
SELECT a.tripId FROM
trip_details a
INNER JOIN
escort_allocation b
ON a.allocationId = b.allocationId
GROUP BY a.allocationId
) AS T