-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQL_test.sql
More file actions
41 lines (33 loc) · 1.17 KB
/
Copy pathSQL_test.sql
File metadata and controls
41 lines (33 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
--Las tablas fueron subidas a BigQuery y las consultas fueron realizadas en él
--¿Qué aerolínea tiene más vuelos?: 7
Select aerolinea from(
SELECT aerolinea, ROW_NUMBER() OVER( partition by null order by count(*) desc) as rank
FROM `test_vuelo`
group by aerolinea
) where rank = 1;
--¿Qué Origen se repite más?: SAP
Select origen from(
SELECT origen, ROW_NUMBER() OVER( partition by null order by count(*) desc) as rank
FROM `test_vuelo`
group by origen
) where rank = 1;
--¿Desde donde vuela más la aerolínea 8?: SAP
Select origen from(
SELECT origen, ROW_NUMBER() OVER( partition by aerolinea order by count(*) desc) as rank
FROM `test_vuelo`
where aerolinea = 8
group by origen,aerolinea
) where rank = 1;
--¿Hacia dónde vuela más la aerolínea 4?: SAP
Select destino from(
SELECT destino, ROW_NUMBER() OVER( partition by aerolinea order by count(*) desc) as rank
FROM `test_vuelo`
where aerolinea = 4
group by destino,aerolinea
) where rank = 1;
----¿Qué piloto vuela más?: 43579
Select codigo_piloto from(
SELECT codigo_piloto, ROW_NUMBER() OVER( partition by null order by count(*) desc) as rank
FROM `test_vuelo`
group by codigo_piloto
) where rank = 1;