Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update sql solution to lc problem: No.0585 #1917

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;