我有一张有许多不同“旅行”的大桌子,我有字段
trip_id (number)
fleet_id (number between 1 and 4)
start zone (number between 1 and 999)
end zone (number between 1 and 999)
我想计算从区域1到区域1,区域1到区域2 ...区域2到区域1,区域2到区域2 ...区域50到区域1等等的多少次旅行。 开始和结束区域也可以为空。
答案 0 :(得分:0)
我认为你需要这样的东西
SELECT
COUNT( trip_id ) AS `count`,
start_zone, end_zone
FROM
trips
WHERE 1
AND start_zone > 0
AND end_zone > 0
GROUP BY
start_zone, end_zone