有没有办法让表格中的所有字段一次性获得所有基数?
有一种方法可以获得一个字段的基数:
SELECT count(distinct year) AS unique_year_cnt FROM default.flight_data_s3;
返回:
示例数据:
presto:default> select * from default.flight_data_s3 limit 10;
year | month | day | day_of_week | dep_time | crs_dep_time | arr_time | crs_arr_time | unique_carrier | flight_num | tail_num | actual
------+-------+-----+-------------+----------+--------------+----------+--------------+----------------+------------+----------+-------
2008 | 12 | 12 | 5 | 1301 | 1305 | 1520 | 1510 | AA | 1715 | N4YAAA |
2008 | 12 | 13 | 6 | 1302 | 1305 | 1518 | 1510 | AA | 1715 | N4XTAA |
2008 | 12 | 14 | 7 | 1302 | 1305 | 1554 | 1510 | AA | 1715 | N438AA |
2008 | 12 | 15 | 1 | 1306 | 1305 | 1549 | 1510 | AA | 1715 | N4WWAA |
2008 | 12 | 16 | 2 | 1324 | 1305 | 1605 | 1510 | AA | 1715 | N4YGAA |
2008 | 12 | 17 | 3 | 1300 | 1305 | 1513 | 1510 | AA | 1715 | N4XFAA |
2008 | 12 | 18 | 4 | 1300 | 1305 | 1544 | 1510 | AA | 1715 | N435AA |
2008 | 12 | 19 | 5 | 1305 | 1305 | 1530 | 1510 | AA | 1715 | N4YRAA |
2008 | 12 | 20 | 6 | 1324 | 1305 | 1544 | 1510 | AA | 1715 | N435AA |
2008 | 12 | 21 | 7 | 1318 | 1305 | 1513 | 1510 | AA | 1715 | N595AA |
(10 rows)