#116. [LeetCode / MySQL] 585. Investments in 2016

문제

 

 

입력 코드

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(pid) > 1)

    AND (lat, lon) IN
        (SELECT lat, lon 
        FROM insurance
        GROUP BY lat, lon
        HAVING COUNT(pid) = 1);

 

 

코드 설명

#SELECT #ROUND #SUM #GROUP BY #HAVING #COUNT #IN

 

 

문제 출처

https://leetcode.com/problems/investments-in-2016/description/?envType=study-plan-v2&envId=top-sql-50