2016년의 총 투자 가치 합계를 조회하는 SQL문을 작성해주세요
한 명 이상의 다른 보험 계약자와 동일한 2015년 총 투자 가치 값을 가지며, 다른 보험 계약자와 같은 도시에 있지 않는 데이터 (lat, lon 값은 중복되지 않아야 합니다).
Write a solution to report the sum of all total investment values in 2016 tiv_2016, for all policyholders who:
have the same tiv_2015 value as one or more other policyholders, and
are not located in the same city as any other policyholder (i.e., the (lat, lon) attribute pairs must be unique). Round tiv_2016 to two decimal places.
SELECT round(sum(tiv_2016),2) as tiv_2016
FROM Insurance
WHERE tiv_2015 in (SELECT tiv_2015
FROM Insurance
GROUP BY tiv_2015
HAVING count(tiv_2015) > 1)
AND pid in (SELECT pid
FROM Insurance
Group by lat, lon
HAVING count(*) = 1)