这是我的查询
SELECT concat(sf.from_location, "-",sf.to_location) as from_to_city,
count( *) as seach_count,
(SELECT count(DISTINCT fb.origin) as no_of_book
FROM flight_booking_details as fb
WHERE fb.status="BOOKING_CONFIRMED" and
from_code=journey_from and
to_code=journey_to AND
DATE(fb.created_datetime) >="2018-07-01" AND
DATE(fb.created_datetime) <="2018-07-04" AND
fb.journey_from = 'BLR' AND
fb.journey_to = 'DEL' ) as booking_count
FROM search_flight_history sf
WHERE DATE(sf.created_datetime) >= '2018-07-01' AND
DATE(sf.created_datetime) <= '2018-07-04' AND
(sf.from_location = 'BLR' OR
sf.from_code = 'BLR') AND
(sf.to_location = 'DEL' OR
sf.to_code = 'DEL')
GROUP BY from_code,
to_code
在这里,我需要找到该查询的总记录。
请任何人帮我找到这个
答案 0 :(得分:0)
如果真的只需要查询返回的行数,则可以尝试以下操作:
select count(*)
from
(
SELECT concat(sf.from_location, "-",sf.to_location) as from_to_city,
count( *) as seach_count,
(SELECT count(DISTINCT fb.origin) as no_of_book
FROM flight_booking_details as fb
WHERE fb.status="BOOKING_CONFIRMED" and
from_code=journey_from and
to_code=journey_to AND
DATE(fb.created_datetime) >="2018-07-01" AND
DATE(fb.created_datetime) <="2018-07-04" AND
fb.journey_from = 'BLR' AND
fb.journey_to = 'DEL' ) as booking_count
FROM search_flight_history sf
WHERE DATE(sf.created_datetime) >= '2018-07-01' AND
DATE(sf.created_datetime) <= '2018-07-04' AND
(sf.from_location = 'BLR' OR
sf.from_code = 'BLR') AND
(sf.to_location = 'DEL' OR
sf.to_code = 'DEL')
GROUP BY from_code,
to_code
) X;