Here i am using JOIN
in 3 tables and getting the count.
- trip_details
- escort_allocation
- cab_allocation
cab_allocation
i am taking Total_Count and escort_allocation
i am taking Escort_Count like trip_details allocationId i am using forien key escort_allocation using inner join i am taking count.Adhoc_Trip_Count i am taking from trip_details
and cab_allocation
.trip_details allocationId i am using forien key cab_allocation using this i am taking count ,my query is working perfect.Now my question is i want to add BETWEEN in two dates.in trip_details table i have one column called tripDate
.suppose i am giving dates like 2018-03-20
INTO 2018-03-23
means , i want fetch records between this two dates
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