我需要一些帮助来选择和显示特定数据。
这是旅行数据,我只想查找第一次和第二次旅行的内容,并且只有第二次旅行是'Home' or 'ReturnFromWork'
。我想看看谁是从家到活动和活动到家的直接旅行。请帮忙,谢谢。
我们假设表名称为FlatFare.csv
Sample Data:
Zone TripNumber TripPurpose
---- --------- --------
1 1 work
1 2 ReturnFromWork
1 1 market
1 2 work
1 3 home
2 1 School
2 2 home
Result:
Zone TripNumber TripPurpose
----- -------- ---------
1 1 work
1 2 ReturnFromWork
2 1 school
2 2 home
答案 0 :(得分:0)
请在SQL中尝试此操作
SELECT Zone, TripNumber, TripPurpose FROM
(SELECT ROW_NUMBER() OVER (PARTITION BY zone ORDER BY zone) AS RowID, * FROM your_TableName) AS Temp
WHERE RowID <=2