Chapter 17 edits
This commit is contained in:
parent
b89e5b9e19
commit
a4bb6851b2
@ -138,11 +138,9 @@ percent_change(new_value numeric,
|
|||||||
old_value numeric,
|
old_value numeric,
|
||||||
decimal_places integer DEFAULT 1)
|
decimal_places integer DEFAULT 1)
|
||||||
RETURNS numeric AS
|
RETURNS numeric AS
|
||||||
$$
|
'SELECT round(
|
||||||
SELECT round(
|
|
||||||
((new_value - old_value) / old_value) * 100, decimal_places
|
((new_value - old_value) / old_value) * 100, decimal_places
|
||||||
);
|
);'
|
||||||
$$
|
|
||||||
LANGUAGE SQL
|
LANGUAGE SQL
|
||||||
IMMUTABLE
|
IMMUTABLE
|
||||||
RETURNS NULL ON NULL INPUT;
|
RETURNS NULL ON NULL INPUT;
|
||||||
@ -151,7 +149,7 @@ RETURNS NULL ON NULL INPUT;
|
|||||||
|
|
||||||
SELECT percent_change(110, 108, 2);
|
SELECT percent_change(110, 108, 2);
|
||||||
|
|
||||||
-- Listing 17-13: Testing percent_change() on Census data
|
-- Listing 17-13: Testing percent_change() on census data
|
||||||
|
|
||||||
SELECT c2019.county_name,
|
SELECT c2019.county_name,
|
||||||
c2019.state_name,
|
c2019.state_name,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user