-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path06.AG06-PopulationDensityDiff.sql
51 lines (36 loc) · 1.14 KB
/
06.AG06-PopulationDensityDiff.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
/*
Population Density Difference
Query the difference between the maximum and minimum populations in CITY.
Input Format
The CITY 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_06populationdensitydiff creation ....',0,1)
GO
CREATE or ALTER PROCEDURE aggregation.proc_06populationdensitydiff (@OutParams int OUT)
AS
SELECT @OutParams = max(population) - min(population) from aggregation.CITY2;
GO
raiserror('Now at AggregationTestClass.test_06populationdensitydiff creation ....',0,1)
GO
CREATE or ALTER PROCEDURE AggregationTestClass.test_06populationdensitydiff
AS
BEGIN
DECLARE @expected int;
DECLARE @actual int;
exec aggregation.proc_06populationdensitydiff @actual OUT
SET @expected = 4695354;
EXEC tSQLt.assertEquals @expected, @actual;
END;
GO
--exec tSQLt.Run 'AggregationTestClass.[test_06populationdensitydiff]';