-
Notifications
You must be signed in to change notification settings - Fork 0
/
06.AG04-AveragePopulation.sql
51 lines (36 loc) · 1.12 KB
/
06.AG04-AveragePopulation.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
/*
Average Population
Query the average population for all cities in CITY2, rounded down to the nearest integer.
Input Format
The CITY2 table is described as follows:
+-------------+--------------+
| Field | Type |
+-------------+--------------+
| ID | number |
| Name | varchar2(17) |
| CountryCode | varchar2(3) |
| District | varchar2(20) |
| Population | number |
+-------------+--------------+
*/
use hackerrank;
GO
raiserror('Now at aggregation.proc_04averagepopulation creation ....',0,1)
GO
CREATE or ALTER PROCEDURE aggregation.proc_04averagepopulation (@OutParams int OUT)
AS
SELECT @OutParams = round(avg(population),0) from aggregation.CITY2;
GO
raiserror('Now at AggregationTestClass.test_04averagepopulation creation ....',0,1)
GO
CREATE or ALTER PROCEDURE AggregationTestClass.test_04averagepopulation
AS
BEGIN
DECLARE @expected int;
DECLARE @actual int;
exec aggregation.proc_04averagepopulation @actual OUT
SET @expected = 454250;
EXEC tSQLt.assertEquals @expected, @actual;
END;
GO
exec tSQLt.Run 'AggregationTestClass.[test_04averagepopulation]';