Skip to content

Commit

Permalink
feat: update sql solution to lc problem: No.0585 (#1917)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkasany authored Nov 2, 2023
1 parent 8a12635 commit 8564bbe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions solution/0500-0599/0585.Investments in 2016/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ WITH
T AS (
SELECT
tiv_2016,
COUNT(pid) OVER (PARTITION BY tiv_2015) AS cnt1,
COUNT(pid) OVER (PARTITION BY CONCAT(lat, '-', lon)) AS cnt2
COUNT(1) OVER (PARTITION BY tiv_2015) AS cnt1,
COUNT(1) OVER (PARTITION BY lat, lon) AS cnt2
FROM Insurance
)
SELECT ROUND(IFNULL(SUM(tiv_2016), 0), 2) AS tiv_2016
SELECT ROUND(SUM(tiv_2016), 2) AS tiv_2016
FROM T
WHERE cnt1 > 1 AND cnt2 = 1;
```
Expand Down
6 changes: 3 additions & 3 deletions solution/0500-0599/0585.Investments in 2016/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ WITH
T AS (
SELECT
tiv_2016,
COUNT(pid) OVER (PARTITION BY tiv_2015) AS cnt1,
COUNT(pid) OVER (PARTITION BY CONCAT(lat, '-', lon)) AS cnt2
COUNT(1) OVER (PARTITION BY tiv_2015) AS cnt1,
COUNT(1) OVER (PARTITION BY lat, lon) AS cnt2
FROM Insurance
)
SELECT ROUND(IFNULL(SUM(tiv_2016), 0), 2) AS tiv_2016
SELECT ROUND(SUM(tiv_2016), 2) AS tiv_2016
FROM T
WHERE cnt1 > 1 AND cnt2 = 1;
```
Expand Down
6 changes: 3 additions & 3 deletions solution/0500-0599/0585.Investments in 2016/Solution.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ WITH
T AS (
SELECT
tiv_2016,
COUNT(pid) OVER (PARTITION BY tiv_2015) AS cnt1,
COUNT(pid) OVER (PARTITION BY CONCAT(lat, '-', lon)) AS cnt2
COUNT(1) OVER (PARTITION BY tiv_2015) AS cnt1,
COUNT(1) OVER (PARTITION BY lat, lon) AS cnt2
FROM Insurance
)
SELECT ROUND(IFNULL(SUM(tiv_2016), 0), 2) AS tiv_2016
SELECT ROUND(SUM(tiv_2016), 2) AS tiv_2016
FROM T
WHERE cnt1 > 1 AND cnt2 = 1;

0 comments on commit 8564bbe

Please sign in to comment.