You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/hackerrank-aggregation.md
+63-2
Original file line number
Diff line number
Diff line change
@@ -99,8 +99,69 @@ where LAT_N is the northern latitude and LONG_W is the western longitude.
99
99
100
100
101
101
102
-
# Weather Observation Station 13
102
+
# Weather Observation Station 13
103
103
104
104
Query the sum of Northern Latitudes (LAT_N) from STATION having values greater than 38.7880 and less than 137.2345. Truncate your answer to 4 decimal places.
105
105
106
-
SELECT ROUND(SUM(lat_n), 4) FROM station WHERE lat_n > 38.7880 AND lat_n < 137.2345;
106
+
SELECT ROUND(SUM(lat_n), 4) FROM station WHERE lat_n > 38.7880 AND lat_n < 137.2345;
107
+
108
+
109
+
110
+
# Weather Observation Station 14
111
+
112
+
Query the greatest value of the Northern Latitudes (LAT_N) from STATION that is less than 137.2345. Truncate your answer to 4 decimal places.
113
+
114
+
SELECT ROUND(MAX(lat_n), 4) FROM station WHERE lat_n < 137.2345;
115
+
116
+
117
+
118
+
# Weather Observation Station 15
119
+
120
+
Query the Western Longitude (LONG_W) for the largest Northern Latitude (LAT_N) in STATION that is less than 137.2345. Round your answer to 4 decimal places.
121
+
122
+
SELECT ROUND(long_w, 4) FROM station WHERE lat_n = (SELECT MAX(lat_n) FROM station WHERE lat_n < 137.2345);
123
+
124
+
125
+
126
+
# Weather Observation Station 16
127
+
128
+
Query the smallest Northern Latitude (LAT_N) from STATION that is greater than 38.7780. Round your answer to 4 decimal places.
129
+
130
+
SELECT ROUND(MIN(lat_n), 4) FROM station WHERE lat_n > 38.7780;
131
+
132
+
133
+
134
+
# Weather Observation Station 17
135
+
136
+
Query the Western Longitude (LONG_W)where the smallest Northern Latitude (LAT_N) in STATION is greater than 38.7780. Round your answer to 4 decimal places.
137
+
138
+
SELECT ROUND(long_w, 4) FROM station WHERE lat_n = (SELECT MIN(lat_n) FROM station WHERE lat_n > 38.7780);
139
+
140
+
141
+
142
+
# Weather Observation Station 18
143
+
144
+
Consider P1(a,b) and P2(c,d) to be two points on a 2D plane.
145
+
a happens to equal the minimum value in Northern Latitude (LAT_N in STATION).
146
+
b happens to equal the minimum value in Western Longitude (LONG_W in STATION).
147
+
c happens to equal the maximum value in Northern Latitude (LAT_N in STATION).
148
+
d happens to equal the maximum value in Western Longitude (LONG_W in STATION).
149
+
150
+
Query the [Manhattan Distance](https://xlinux.nist.gov/dads/HTML/manhattanDistance.html) between points P1 and P2 and round it to a scale of 4 decimal places.
151
+
152
+
SELECT ROUND(ABS(a - c) + ABS(b - d), 4) FROM (
153
+
SELECT MIN(lat_n) AS a, MIN(long_w) AS b, MAX(lat_n) AS c, MAX(long_w) AS d FROM station);
154
+
155
+
156
+
157
+
# Weather Observation Station 19
158
+
159
+
Consider P1(a,c) and P2(b,d) to be two points on a 2D plane.
160
+
(a,b) - the respective minimum and maximum values of Northern Latitude (LAT_N)
161
+
(c,d) - the respective minimum and maximum values of Western Longitude (LONG_W) in STATION.
162
+
163
+
Query the [Euclidean Distance](https://en.wikipedia.org/wiki/Euclidean_distance) between points P1 and P2 and format your answer to display 4 decimal digits.
164
+
165
+
SELECT ROUND (SQRT((a - b) * (a - b) + (c - d) * (c - d)), 4) FROM (
166
+
SELECT MIN(lat_n) AS a, MAX(lat_n) AS b, MIN(long_w) AS c, MAX(long_w) AS d FROM station);
0 commit comments