2020-11-27 11:23:28 +00:00
|
|
|
|
---
|
2022-08-26 19:07:59 +00:00
|
|
|
|
slug: /zh/getting-started/example-datasets/ontime
|
2022-04-10 23:08:18 +00:00
|
|
|
|
sidebar_position: 21
|
|
|
|
|
sidebar_label: OnTime
|
2020-11-27 11:23:28 +00:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# OnTime {#ontime}
|
2018-10-17 08:19:33 +00:00
|
|
|
|
|
2019-10-29 06:26:54 +00:00
|
|
|
|
航班飞行数据有以下两个方式获取:
|
|
|
|
|
|
2020-03-21 04:11:51 +00:00
|
|
|
|
- 从原始数据导入
|
2020-11-27 11:23:28 +00:00
|
|
|
|
- 下载预处理好的数据
|
2019-10-29 06:26:54 +00:00
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
## 从原始数据导入 {#cong-yuan-shi-shu-ju-dao-ru}
|
2019-10-29 06:26:54 +00:00
|
|
|
|
|
2018-10-17 08:19:33 +00:00
|
|
|
|
下载数据:
|
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
``` bash
|
2021-12-24 16:34:18 +00:00
|
|
|
|
wget --no-check-certificate --continue https://transtats.bts.gov/PREZIP/On_Time_Reporting_Carrier_On_Time_Performance_1987_present_{1987..2021}_{1..12}.zip
|
2018-10-17 08:19:33 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
创建表结构:
|
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
``` sql
|
2021-02-23 12:08:01 +00:00
|
|
|
|
CREATE TABLE `ontime`
|
|
|
|
|
(
|
|
|
|
|
`Year` UInt16,
|
|
|
|
|
`Quarter` UInt8,
|
|
|
|
|
`Month` UInt8,
|
|
|
|
|
`DayofMonth` UInt8,
|
|
|
|
|
`DayOfWeek` UInt8,
|
|
|
|
|
`FlightDate` Date,
|
|
|
|
|
`Reporting_Airline` String,
|
|
|
|
|
`DOT_ID_Reporting_Airline` Int32,
|
|
|
|
|
`IATA_CODE_Reporting_Airline` String,
|
2021-12-24 16:34:18 +00:00
|
|
|
|
`Tail_Number` String,
|
2021-02-23 12:08:01 +00:00
|
|
|
|
`Flight_Number_Reporting_Airline` String,
|
|
|
|
|
`OriginAirportID` Int32,
|
|
|
|
|
`OriginAirportSeqID` Int32,
|
|
|
|
|
`OriginCityMarketID` Int32,
|
|
|
|
|
`Origin` FixedString(5),
|
|
|
|
|
`OriginCityName` String,
|
|
|
|
|
`OriginState` FixedString(2),
|
|
|
|
|
`OriginStateFips` String,
|
|
|
|
|
`OriginStateName` String,
|
|
|
|
|
`OriginWac` Int32,
|
|
|
|
|
`DestAirportID` Int32,
|
|
|
|
|
`DestAirportSeqID` Int32,
|
|
|
|
|
`DestCityMarketID` Int32,
|
|
|
|
|
`Dest` FixedString(5),
|
|
|
|
|
`DestCityName` String,
|
|
|
|
|
`DestState` FixedString(2),
|
|
|
|
|
`DestStateFips` String,
|
|
|
|
|
`DestStateName` String,
|
|
|
|
|
`DestWac` Int32,
|
|
|
|
|
`CRSDepTime` Int32,
|
|
|
|
|
`DepTime` Int32,
|
|
|
|
|
`DepDelay` Int32,
|
|
|
|
|
`DepDelayMinutes` Int32,
|
|
|
|
|
`DepDel15` Int32,
|
|
|
|
|
`DepartureDelayGroups` String,
|
|
|
|
|
`DepTimeBlk` String,
|
|
|
|
|
`TaxiOut` Int32,
|
|
|
|
|
`WheelsOff` Int32,
|
|
|
|
|
`WheelsOn` Int32,
|
|
|
|
|
`TaxiIn` Int32,
|
|
|
|
|
`CRSArrTime` Int32,
|
|
|
|
|
`ArrTime` Int32,
|
|
|
|
|
`ArrDelay` Int32,
|
|
|
|
|
`ArrDelayMinutes` Int32,
|
|
|
|
|
`ArrDel15` Int32,
|
|
|
|
|
`ArrivalDelayGroups` Int32,
|
|
|
|
|
`ArrTimeBlk` String,
|
|
|
|
|
`Cancelled` UInt8,
|
|
|
|
|
`CancellationCode` FixedString(1),
|
|
|
|
|
`Diverted` UInt8,
|
|
|
|
|
`CRSElapsedTime` Int32,
|
|
|
|
|
`ActualElapsedTime` Int32,
|
|
|
|
|
`AirTime` Nullable(Int32),
|
|
|
|
|
`Flights` Int32,
|
|
|
|
|
`Distance` Int32,
|
|
|
|
|
`DistanceGroup` UInt8,
|
|
|
|
|
`CarrierDelay` Int32,
|
|
|
|
|
`WeatherDelay` Int32,
|
|
|
|
|
`NASDelay` Int32,
|
|
|
|
|
`SecurityDelay` Int32,
|
|
|
|
|
`LateAircraftDelay` Int32,
|
|
|
|
|
`FirstDepTime` String,
|
|
|
|
|
`TotalAddGTime` String,
|
|
|
|
|
`LongestAddGTime` String,
|
|
|
|
|
`DivAirportLandings` String,
|
|
|
|
|
`DivReachedDest` String,
|
|
|
|
|
`DivActualElapsedTime` String,
|
|
|
|
|
`DivArrDelay` String,
|
|
|
|
|
`DivDistance` String,
|
|
|
|
|
`Div1Airport` String,
|
|
|
|
|
`Div1AirportID` Int32,
|
|
|
|
|
`Div1AirportSeqID` Int32,
|
|
|
|
|
`Div1WheelsOn` String,
|
|
|
|
|
`Div1TotalGTime` String,
|
|
|
|
|
`Div1LongestGTime` String,
|
|
|
|
|
`Div1WheelsOff` String,
|
|
|
|
|
`Div1TailNum` String,
|
|
|
|
|
`Div2Airport` String,
|
|
|
|
|
`Div2AirportID` Int32,
|
|
|
|
|
`Div2AirportSeqID` Int32,
|
|
|
|
|
`Div2WheelsOn` String,
|
|
|
|
|
`Div2TotalGTime` String,
|
|
|
|
|
`Div2LongestGTime` String,
|
|
|
|
|
`Div2WheelsOff` String,
|
|
|
|
|
`Div2TailNum` String,
|
|
|
|
|
`Div3Airport` String,
|
|
|
|
|
`Div3AirportID` Int32,
|
|
|
|
|
`Div3AirportSeqID` Int32,
|
|
|
|
|
`Div3WheelsOn` String,
|
|
|
|
|
`Div3TotalGTime` String,
|
|
|
|
|
`Div3LongestGTime` String,
|
|
|
|
|
`Div3WheelsOff` String,
|
|
|
|
|
`Div3TailNum` String,
|
|
|
|
|
`Div4Airport` String,
|
|
|
|
|
`Div4AirportID` Int32,
|
|
|
|
|
`Div4AirportSeqID` Int32,
|
|
|
|
|
`Div4WheelsOn` String,
|
|
|
|
|
`Div4TotalGTime` String,
|
|
|
|
|
`Div4LongestGTime` String,
|
|
|
|
|
`Div4WheelsOff` String,
|
|
|
|
|
`Div4TailNum` String,
|
|
|
|
|
`Div5Airport` String,
|
|
|
|
|
`Div5AirportID` Int32,
|
|
|
|
|
`Div5AirportSeqID` Int32,
|
|
|
|
|
`Div5WheelsOn` String,
|
|
|
|
|
`Div5TotalGTime` String,
|
|
|
|
|
`Div5LongestGTime` String,
|
|
|
|
|
`Div5WheelsOff` String,
|
|
|
|
|
`Div5TailNum` String
|
2020-03-20 18:20:59 +00:00
|
|
|
|
) ENGINE = MergeTree
|
2021-02-23 12:08:01 +00:00
|
|
|
|
PARTITION BY Year
|
2021-02-23 14:14:22 +00:00
|
|
|
|
ORDER BY (IATA_CODE_Reporting_Airline, FlightDate)
|
2021-02-23 12:08:01 +00:00
|
|
|
|
SETTINGS index_granularity = 8192;
|
2018-10-17 08:19:33 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
加载数据:
|
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
``` bash
|
2021-05-02 11:19:11 +00:00
|
|
|
|
ls -1 *.zip | xargs -I{} -P $(nproc) bash -c "echo {}; unzip -cq {} '*.csv' | sed 's/\.00//g' | clickhouse-client --input_format_with_names_use_header=0 --query='INSERT INTO ontime FORMAT CSVWithNames'"
|
2018-10-17 08:19:33 +00:00
|
|
|
|
```
|
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
## 下载预处理好的分区数据 {#xia-zai-yu-chu-li-hao-de-fen-qu-shu-ju}
|
2019-10-29 06:26:54 +00:00
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
``` bash
|
2021-09-22 00:22:57 +00:00
|
|
|
|
$ curl -O https://datasets.clickhouse.com/ontime/partitions/ontime.tar
|
2019-10-29 06:26:54 +00:00
|
|
|
|
$ tar xvf ontime.tar -C /var/lib/clickhouse # path to ClickHouse data directory
|
|
|
|
|
$ # check permissions of unpacked data, fix if required
|
|
|
|
|
$ sudo service clickhouse-server restart
|
|
|
|
|
$ clickhouse-client --query "select count(*) from datasets.ontime"
|
|
|
|
|
```
|
2020-03-20 18:20:59 +00:00
|
|
|
|
|
2020-04-08 14:22:25 +00:00
|
|
|
|
!!! info "信息"
|
2020-11-27 11:23:28 +00:00
|
|
|
|
如果要运行下面的SQL查询,必须使用完整的表名,`datasets.ontime`。
|
2019-10-29 06:26:54 +00:00
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
## 查询: {#cha-xun}
|
2018-10-17 08:19:33 +00:00
|
|
|
|
|
|
|
|
|
Q0.
|
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
``` sql
|
2019-10-28 04:18:22 +00:00
|
|
|
|
SELECT avg(c1)
|
|
|
|
|
FROM
|
|
|
|
|
(
|
|
|
|
|
SELECT Year, Month, count(*) AS c1
|
|
|
|
|
FROM ontime
|
|
|
|
|
GROUP BY Year, Month
|
|
|
|
|
);
|
2018-10-17 08:19:33 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Q1. 查询从2000年到2008年每天的航班数
|
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
``` sql
|
2019-10-28 04:18:22 +00:00
|
|
|
|
SELECT DayOfWeek, count(*) AS c
|
|
|
|
|
FROM ontime
|
|
|
|
|
WHERE Year>=2000 AND Year<=2008
|
|
|
|
|
GROUP BY DayOfWeek
|
|
|
|
|
ORDER BY c DESC;
|
2018-10-17 08:19:33 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Q2. 查询从2000年到2008年每周延误超过10分钟的航班数。
|
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
``` sql
|
2019-10-28 04:18:22 +00:00
|
|
|
|
SELECT DayOfWeek, count(*) AS c
|
|
|
|
|
FROM ontime
|
|
|
|
|
WHERE DepDelay>10 AND Year>=2000 AND Year<=2008
|
|
|
|
|
GROUP BY DayOfWeek
|
|
|
|
|
ORDER BY c DESC;
|
2018-10-17 08:19:33 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Q3. 查询2000年到2008年每个机场延误超过10分钟以上的次数
|
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
``` sql
|
2019-10-28 04:18:22 +00:00
|
|
|
|
SELECT Origin, count(*) AS c
|
|
|
|
|
FROM ontime
|
|
|
|
|
WHERE DepDelay>10 AND Year>=2000 AND Year<=2008
|
|
|
|
|
GROUP BY Origin
|
|
|
|
|
ORDER BY c DESC
|
|
|
|
|
LIMIT 10;
|
2018-10-17 08:19:33 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Q4. 查询2007年各航空公司延误超过10分钟以上的次数
|
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
``` sql
|
2021-02-23 14:14:22 +00:00
|
|
|
|
SELECT IATA_CODE_Reporting_Airline AS Carrier, count(*)
|
2019-10-28 04:18:22 +00:00
|
|
|
|
FROM ontime
|
|
|
|
|
WHERE DepDelay>10 AND Year=2007
|
|
|
|
|
GROUP BY Carrier
|
|
|
|
|
ORDER BY count(*) DESC;
|
2018-10-17 08:19:33 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Q5. 查询2007年各航空公司延误超过10分钟以上的百分比
|
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
``` sql
|
2019-06-05 23:43:12 +00:00
|
|
|
|
SELECT Carrier, c, c2, c*100/c2 as c3
|
2018-10-17 08:19:33 +00:00
|
|
|
|
FROM
|
|
|
|
|
(
|
|
|
|
|
SELECT
|
2021-02-23 14:14:22 +00:00
|
|
|
|
IATA_CODE_Reporting_Airline AS Carrier,
|
2018-10-17 08:19:33 +00:00
|
|
|
|
count(*) AS c
|
|
|
|
|
FROM ontime
|
|
|
|
|
WHERE DepDelay>10
|
|
|
|
|
AND Year=2007
|
|
|
|
|
GROUP BY Carrier
|
2021-02-23 14:14:22 +00:00
|
|
|
|
) q
|
2020-03-17 18:10:23 +00:00
|
|
|
|
JOIN
|
2018-10-17 08:19:33 +00:00
|
|
|
|
(
|
|
|
|
|
SELECT
|
2021-02-23 14:14:22 +00:00
|
|
|
|
IATA_CODE_Reporting_Airline AS Carrier,
|
2018-10-17 08:19:33 +00:00
|
|
|
|
count(*) AS c2
|
|
|
|
|
FROM ontime
|
|
|
|
|
WHERE Year=2007
|
|
|
|
|
GROUP BY Carrier
|
2021-02-23 14:14:22 +00:00
|
|
|
|
) qq USING Carrier
|
2018-10-17 08:19:33 +00:00
|
|
|
|
ORDER BY c3 DESC;
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
更好的查询版本:
|
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
``` sql
|
2021-02-23 14:14:22 +00:00
|
|
|
|
SELECT IATA_CODE_Reporting_Airline AS Carrier, avg(DepDelay>10)*100 AS c3
|
2019-10-28 04:18:22 +00:00
|
|
|
|
FROM ontime
|
|
|
|
|
WHERE Year=2007
|
|
|
|
|
GROUP BY Carrier
|
2020-03-17 18:10:23 +00:00
|
|
|
|
ORDER BY c3 DESC
|
2018-10-17 08:19:33 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Q6. 同上一个查询一致,只是查询范围扩大到2000年到2008年
|
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
``` sql
|
2019-06-05 23:43:12 +00:00
|
|
|
|
SELECT Carrier, c, c2, c*100/c2 as c3
|
2018-10-17 08:19:33 +00:00
|
|
|
|
FROM
|
|
|
|
|
(
|
|
|
|
|
SELECT
|
2021-02-23 14:14:22 +00:00
|
|
|
|
IATA_CODE_Reporting_Airline AS Carrier,
|
2018-10-17 08:19:33 +00:00
|
|
|
|
count(*) AS c
|
|
|
|
|
FROM ontime
|
|
|
|
|
WHERE DepDelay>10
|
2019-10-28 04:18:22 +00:00
|
|
|
|
AND Year>=2000 AND Year<=2008
|
2018-10-17 08:19:33 +00:00
|
|
|
|
GROUP BY Carrier
|
2021-02-23 14:14:22 +00:00
|
|
|
|
) q
|
2020-03-17 18:10:23 +00:00
|
|
|
|
JOIN
|
2018-10-17 08:19:33 +00:00
|
|
|
|
(
|
|
|
|
|
SELECT
|
2021-02-23 14:14:22 +00:00
|
|
|
|
IATA_CODE_Reporting_Airline AS Carrier,
|
2018-10-17 08:19:33 +00:00
|
|
|
|
count(*) AS c2
|
|
|
|
|
FROM ontime
|
2019-10-28 04:18:22 +00:00
|
|
|
|
WHERE Year>=2000 AND Year<=2008
|
2018-10-17 08:19:33 +00:00
|
|
|
|
GROUP BY Carrier
|
2021-02-23 14:14:22 +00:00
|
|
|
|
) qq USING Carrier
|
2018-10-17 08:19:33 +00:00
|
|
|
|
ORDER BY c3 DESC;
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
更好的查询版本:
|
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
``` sql
|
2021-02-23 14:14:22 +00:00
|
|
|
|
SELECT IATA_CODE_Reporting_Airline AS Carrier, avg(DepDelay>10)*100 AS c3
|
2019-10-28 04:18:22 +00:00
|
|
|
|
FROM ontime
|
|
|
|
|
WHERE Year>=2000 AND Year<=2008
|
|
|
|
|
GROUP BY Carrier
|
2020-03-17 18:10:23 +00:00
|
|
|
|
ORDER BY c3 DESC;
|
2018-10-17 08:19:33 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Q7. 每年航班延误超过10分钟的百分比
|
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
``` sql
|
2018-10-17 08:19:33 +00:00
|
|
|
|
SELECT Year, c1/c2
|
|
|
|
|
FROM
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
Year,
|
2019-06-05 23:43:12 +00:00
|
|
|
|
count(*)*100 as c1
|
2018-10-17 08:19:33 +00:00
|
|
|
|
from ontime
|
|
|
|
|
WHERE DepDelay>10
|
|
|
|
|
GROUP BY Year
|
2021-02-23 14:14:22 +00:00
|
|
|
|
) q
|
2020-03-17 18:10:23 +00:00
|
|
|
|
JOIN
|
2018-10-17 08:19:33 +00:00
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
Year,
|
|
|
|
|
count(*) as c2
|
|
|
|
|
from ontime
|
|
|
|
|
GROUP BY Year
|
2021-02-23 14:14:22 +00:00
|
|
|
|
) qq USING (Year)
|
2019-10-28 04:18:22 +00:00
|
|
|
|
ORDER BY Year;
|
2018-10-17 08:19:33 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
更好的查询版本:
|
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
``` sql
|
2020-03-17 18:10:23 +00:00
|
|
|
|
SELECT Year, avg(DepDelay>10)*100
|
2019-10-28 04:18:22 +00:00
|
|
|
|
FROM ontime
|
|
|
|
|
GROUP BY Year
|
|
|
|
|
ORDER BY Year;
|
2018-10-17 08:19:33 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Q8. 每年更受人们喜爱的目的地
|
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
``` sql
|
2019-10-28 04:18:22 +00:00
|
|
|
|
SELECT DestCityName, uniqExact(OriginCityName) AS u
|
|
|
|
|
FROM ontime
|
|
|
|
|
WHERE Year >= 2000 and Year <= 2010
|
|
|
|
|
GROUP BY DestCityName
|
|
|
|
|
ORDER BY u DESC LIMIT 10;
|
2018-10-17 08:19:33 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Q9.
|
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
``` sql
|
2019-10-28 04:18:22 +00:00
|
|
|
|
SELECT Year, count(*) AS c1
|
|
|
|
|
FROM ontime
|
|
|
|
|
GROUP BY Year;
|
2018-10-17 08:19:33 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Q10.
|
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
``` sql
|
2019-10-28 04:18:22 +00:00
|
|
|
|
SELECT
|
2021-02-23 14:14:22 +00:00
|
|
|
|
min(Year), max(Year), IATA_CODE_Reporting_Airline AS Carrier, count(*) AS cnt,
|
2019-10-28 04:18:22 +00:00
|
|
|
|
sum(ArrDelayMinutes>30) AS flights_delayed,
|
|
|
|
|
round(sum(ArrDelayMinutes>30)/count(*),2) AS rate
|
2018-10-17 08:19:33 +00:00
|
|
|
|
FROM ontime
|
|
|
|
|
WHERE
|
2019-10-28 04:18:22 +00:00
|
|
|
|
DayOfWeek NOT IN (6,7) AND OriginState NOT IN ('AK', 'HI', 'PR', 'VI')
|
|
|
|
|
AND DestState NOT IN ('AK', 'HI', 'PR', 'VI')
|
|
|
|
|
AND FlightDate < '2010-01-01'
|
2018-10-17 08:19:33 +00:00
|
|
|
|
GROUP by Carrier
|
2019-10-28 04:18:22 +00:00
|
|
|
|
HAVING cnt>100000 and max(Year)>1990
|
2018-10-17 08:19:33 +00:00
|
|
|
|
ORDER by rate DESC
|
|
|
|
|
LIMIT 1000;
|
|
|
|
|
```
|
|
|
|
|
|
2020-11-27 11:23:28 +00:00
|
|
|
|
Bonus:
|
2018-10-17 08:19:33 +00:00
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
``` sql
|
2019-10-28 04:18:22 +00:00
|
|
|
|
SELECT avg(cnt)
|
|
|
|
|
FROM
|
|
|
|
|
(
|
|
|
|
|
SELECT Year,Month,count(*) AS cnt
|
|
|
|
|
FROM ontime
|
|
|
|
|
WHERE DepDel15=1
|
|
|
|
|
GROUP BY Year,Month
|
|
|
|
|
);
|
2018-10-17 08:19:33 +00:00
|
|
|
|
|
2019-10-28 04:18:22 +00:00
|
|
|
|
SELECT avg(c1) FROM
|
|
|
|
|
(
|
|
|
|
|
SELECT Year,Month,count(*) AS c1
|
|
|
|
|
FROM ontime
|
|
|
|
|
GROUP BY Year,Month
|
|
|
|
|
);
|
2018-10-17 08:19:33 +00:00
|
|
|
|
|
2019-10-28 04:18:22 +00:00
|
|
|
|
SELECT DestCityName, uniqExact(OriginCityName) AS u
|
|
|
|
|
FROM ontime
|
|
|
|
|
GROUP BY DestCityName
|
|
|
|
|
ORDER BY u DESC
|
|
|
|
|
LIMIT 10;
|
2018-10-17 08:19:33 +00:00
|
|
|
|
|
2019-10-28 04:18:22 +00:00
|
|
|
|
SELECT OriginCityName, DestCityName, count() AS c
|
|
|
|
|
FROM ontime
|
|
|
|
|
GROUP BY OriginCityName, DestCityName
|
|
|
|
|
ORDER BY c DESC
|
|
|
|
|
LIMIT 10;
|
2018-10-17 08:19:33 +00:00
|
|
|
|
|
2019-10-28 04:18:22 +00:00
|
|
|
|
SELECT OriginCityName, count() AS c
|
|
|
|
|
FROM ontime
|
|
|
|
|
GROUP BY OriginCityName
|
|
|
|
|
ORDER BY c DESC
|
|
|
|
|
LIMIT 10;
|
2018-10-17 08:19:33 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
这个性能测试由Vadim Tkachenko提供。参考:
|
|
|
|
|
|
2020-03-21 04:11:51 +00:00
|
|
|
|
- https://www.percona.com/blog/2009/10/02/analyzing-air-traffic-performance-with-infobright-and-monetdb/
|
|
|
|
|
- https://www.percona.com/blog/2009/10/26/air-traffic-queries-in-luciddb/
|
|
|
|
|
- https://www.percona.com/blog/2009/11/02/air-traffic-queries-in-infinidb-early-alpha/
|
|
|
|
|
- https://www.percona.com/blog/2014/04/21/using-apache-hadoop-and-impala-together-with-mysql-for-data-analysis/
|
|
|
|
|
- https://www.percona.com/blog/2016/01/07/apache-spark-with-air-ontime-performance-data/
|
|
|
|
|
- http://nickmakos.blogspot.ru/2012/08/analyzing-air-traffic-performance-with.html
|