Skip to content

Commit 6b9e9d7

Browse files
refactor 585:
1 parent 79ea98e commit 6b9e9d7

File tree

1 file changed

+0
-44
lines changed

1 file changed

+0
-44
lines changed

Diff for: database/_585.sql

-44
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,3 @@
1-
--585. Investments in 2016
2-
--Write a query to print the sum of all total investment values in 2016 (TIV_2016), to a scale of 2 decimal places,
3-
--for all policy holders who meet the following criteria:
4-
--
5-
--Have the same TIV_2015 value as one or more other policyholders.
6-
--Are not located in the same city as any other policyholder (i.e.: the (latitude, longitude) attribute pairs must be unique).
7-
--Input Format:
8-
--The insurance table is described as follows:
9-
--
10-
--| Column Name | Type |
11-
--|-------------|---------------|
12-
--| PID | INTEGER(11) |
13-
--| TIV_2015 | NUMERIC(15,2) |
14-
--| TIV_2016 | NUMERIC(15,2) |
15-
--| LAT | NUMERIC(5,2) |
16-
--| LON | NUMERIC(5,2) |
17-
--where PID is the policyholder's policy ID,
18-
--TIV_2015 is the total investment value in 2015, TIV_2016 is the total investment value in 2016,
19-
--LAT is the latitude of the policy holder's city, and LON is the longitude of the policy holder's city.
20-
--
21-
--Sample Input
22-
--
23-
--| PID | TIV_2015 | TIV_2016 | LAT | LON |
24-
--|-----|----------|----------|-----|-----|
25-
--| 1 | 10 | 5 | 10 | 10 |
26-
--| 2 | 20 | 20 | 20 | 20 |
27-
--| 3 | 10 | 30 | 20 | 20 |
28-
--| 4 | 10 | 40 | 40 | 40 |
29-
--Sample Output
30-
--
31-
--| TIV_2016 |
32-
--|----------|
33-
--| 45.00 |
34-
--Explanation
35-
--
36-
--The first record in the table, like the last record, meets both of the two criteria.
37-
--The TIV_2015 value '10' is as the same as the third and forth record, and its location unique.
38-
--
39-
--The second record does not meet any of the two criteria. Its TIV_2015 is not like any other policyholders.
40-
--
41-
--And its location is the same with the third record, which makes the third record fail, too.
42-
--
43-
--So, the result is the sum of TIV_2016 of the first and last record, which is 45.
44-
451
select sum(TIV_2016) as TIV_2016
462
from insurance a where
473
(

0 commit comments

Comments
 (0)