From e5b07b858dc4466aa3025d8ce21fe7e2b018cddc Mon Sep 17 00:00:00 2001 From: thinkasany <480968828@qq.com> Date: Fri, 3 Nov 2023 01:28:27 +0800 Subject: [PATCH] feat: update sql solution to lc problem: No.0585 --- solution/0500-0599/0585.Investments in 2016/README.md | 6 +++--- solution/0500-0599/0585.Investments in 2016/README_EN.md | 6 +++--- solution/0500-0599/0585.Investments in 2016/Solution.sql | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/solution/0500-0599/0585.Investments in 2016/README.md b/solution/0500-0599/0585.Investments in 2016/README.md index ec13524ed04fa..fb0f5002173a1 100644 --- a/solution/0500-0599/0585.Investments in 2016/README.md +++ b/solution/0500-0599/0585.Investments in 2016/README.md @@ -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; ``` diff --git a/solution/0500-0599/0585.Investments in 2016/README_EN.md b/solution/0500-0599/0585.Investments in 2016/README_EN.md index 904c272d183c1..8df8213cc0241 100644 --- a/solution/0500-0599/0585.Investments in 2016/README_EN.md +++ b/solution/0500-0599/0585.Investments in 2016/README_EN.md @@ -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; ``` diff --git a/solution/0500-0599/0585.Investments in 2016/Solution.sql b/solution/0500-0599/0585.Investments in 2016/Solution.sql index 30b95dc8c0837..b7d9180a1244c 100644 --- a/solution/0500-0599/0585.Investments in 2016/Solution.sql +++ b/solution/0500-0599/0585.Investments in 2016/Solution.sql @@ -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;