-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path04.BS11-WeatherObservationStation06.sql
143 lines (117 loc) · 4.69 KB
/
04.BS11-WeatherObservationStation06.sql
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
Weather Observation Station 6
Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION. Your result cannot contain duplicates.
Input Format
The STATION table is described as follows:
+--------+--------------+
| FILEDS | TYPE |
+--------+--------------+
| ID | NUMBER |
| CITY | VARCHAR2(21) |
| STATE | VARCHAR2(2) |
| LAT_N | NUMBER |
| LONG_W | NUMBER |
+--------+--------------+
where LAT_N is the northern latitude and LONG_W is the western longitude.
Sample Input
Let's say that CITY only has four entries: DEF, ABC, PQRS and WXY
Sample Output
ABC 3
PQRS 4
Explanation
When ordered alphabetically, the CITY names are listed as ABC, DEF, PQRS, and WXY, with the respective lengths 3, 3, 4 and 3. The longest-named city is obviously PQRS, but there are 3 options for shortest-named city; we choose ABC, because it comes first alphabetically.
Note
You can write two separate queries to get the desired output. It need not be a single query.
*/
use hackerrank;
GO
raiserror('Now at the create procedure section ....',0,1)
GO
CREATE or ALTER PROCEDURE basicselect.proc_11wos06 AS
select
distinct(city)
from
basicselect.STATION
where
upper(substring(city, 1,1)) in ('A','E','I','O','U');
GO
CREATE or ALTER PROCEDURE BasicSelectTestClass.test_11wos06 AS
BEGIN
IF OBJECT_ID('actual') IS NOT NULL DROP TABLE actual;
IF OBJECT_ID('expected') IS NOT NULL DROP TABLE expected;
CREATE TABLE actual (
CITY varchar(21)
);
INSERT INTO actual (CITY) exec basicselect.proc_11wos06
CREATE TABLE expected (
CITY varchar(21)
);
INSERT INTO expected (CITY) select 'Acme'
INSERT INTO expected (CITY) select 'Addison'
INSERT INTO expected (CITY) select 'Agency'
INSERT INTO expected (CITY) select 'Aguanga'
INSERT INTO expected (CITY) select 'Alanson'
INSERT INTO expected (CITY) select 'Alba'
INSERT INTO expected (CITY) select 'Albany'
INSERT INTO expected (CITY) select 'Albion'
INSERT INTO expected (CITY) select 'Algonac'
INSERT INTO expected (CITY) select 'Aliso Viejo'
INSERT INTO expected (CITY) select 'Allerton'
INSERT INTO expected (CITY) select 'Alpine'
INSERT INTO expected (CITY) select 'Alton'
INSERT INTO expected (CITY) select 'Amazonia'
INSERT INTO expected (CITY) select 'Amo'
INSERT INTO expected (CITY) select 'Andersonville'
INSERT INTO expected (CITY) select 'Andover'
INSERT INTO expected (CITY) select 'Anthony'
INSERT INTO expected (CITY) select 'Archie'
INSERT INTO expected (CITY) select 'Arispe'
INSERT INTO expected (CITY) select 'Arkadelphia'
INSERT INTO expected (CITY) select 'Arlington'
INSERT INTO expected (CITY) select 'Arrowsmith'
INSERT INTO expected (CITY) select 'Athens'
INSERT INTO expected (CITY) select 'Atlantic Mine'
INSERT INTO expected (CITY) select 'Auburn'
INSERT INTO expected (CITY) select 'East China'
INSERT INTO expected (CITY) select 'East Haddam'
INSERT INTO expected (CITY) select 'East Irvine'
INSERT INTO expected (CITY) select 'Eastlake'
INSERT INTO expected (CITY) select 'Edgewater'
INSERT INTO expected (CITY) select 'Effingham'
INSERT INTO expected (CITY) select 'Eleele'
INSERT INTO expected (CITY) select 'Elkton'
INSERT INTO expected (CITY) select 'Elm Grove'
INSERT INTO expected (CITY) select 'Emmett'
INSERT INTO expected (CITY) select 'Equality'
INSERT INTO expected (CITY) select 'Eriline'
INSERT INTO expected (CITY) select 'Ermine'
INSERT INTO expected (CITY) select 'Eros'
INSERT INTO expected (CITY) select 'Eskridge'
INSERT INTO expected (CITY) select 'Esmond'
INSERT INTO expected (CITY) select 'Eufaula'
INSERT INTO expected (CITY) select 'Eureka Springs'
INSERT INTO expected (CITY) select 'Eustis'
INSERT INTO expected (CITY) select 'Everton'
INSERT INTO expected (CITY) select 'Irvington'
INSERT INTO expected (CITY) select 'Oakfield'
INSERT INTO expected (CITY) select 'Oconee'
INSERT INTO expected (CITY) select 'Odin'
INSERT INTO expected (CITY) select 'Ojai'
INSERT INTO expected (CITY) select 'Olmitz'
INSERT INTO expected (CITY) select 'Onaway'
INSERT INTO expected (CITY) select 'Orange City'
INSERT INTO expected (CITY) select 'Orange Park'
INSERT INTO expected (CITY) select 'Osage City'
INSERT INTO expected (CITY) select 'Osborne'
INSERT INTO expected (CITY) select 'Oshtemo'
INSERT INTO expected (CITY) select 'Ottertail'
INSERT INTO expected (CITY) select 'Ozona'
INSERT INTO expected (CITY) select 'Udall'
INSERT INTO expected (CITY) select 'Ukiah'
INSERT INTO expected (CITY) select 'Union Star'
INSERT INTO expected (CITY) select 'Upperco'
INSERT INTO expected (CITY) select 'Urbana'
EXEC tSQLt.AssertEqualsTable 'expected', 'actual';
END;
GO
--exec tSQLt.Run 'BasicSelectTestClass.[test_11wos06]';