将 DENSE_RANK() 与左外连接一起使用
Use DENSE_RANK() with left outer join
我正在使用上面的代码对 jira.releases table:
执行左连接
SELECT b.*,c.releasedate from digitalpfatforms.issues_braze b
Left join jira.releases c
On b.version_id=c.versionid
有了这个,我得到了以下预期输出:
issueid
sprintid
sprintenddate
version_id
releasedate
1945
85
20/11/2021
45699
25/11/2021
1836
90
01/12/2021
54555
05/12/2021
1836
90
01/12/2021
54555
05/12/2021
2000
55
10/11/2021
56777
15/11/2021
2000
55
10/11/2021
56777
15/11/2021
2000
55
10/11/2021
56777
15/11/2021
根据这个输出,我需要计算 2 dense_rank()。超过 sprintenddate:
DENSE_RANK() OVER(ORDER BY b.sprintenddate DESC) AS "rank_sprint"
和另一个过度释放:
DENSE_RANK() OVER(ORDER BY c.releasedate DESC) AS "rank_release"
我的预期输出是:
issueid
sprintid
sprintenddate
version_id
releasedate
rank_sprint
rank_release
1945
85
20/11/2021
45699
25/11/2021
2
2
1836
90
01/12/2021
54555
05/12/2021
1
1
1836
90
01/12/2021
54555
05/12/2021
1
1
2000
55
10/11/2021
56777
15/11/2021
3
3
2000
55
10/11/2021
56777
15/11/2021
3
3
2000
55
10/11/2021
56777
15/11/2021
3
3
任何人都可以帮助我如何组合 SQL 查询,以便它执行连接并计算提到的 dense_rank?
谢谢
看起来您已经完成了所有工作。把所有的部分加在一起就可以了。
SELECT b.*,
c.releasedate,
DENSE_RANK() OVER(ORDER BY b.sprintenddate DESC) AS "rank_sprint",
DENSE_RANK() OVER(ORDER BY c.releasedate DESC) AS "rank_release"
from digitalpfatforms.issues_braze b
left join jira.releases c on b.version_id=c.versionid
我正在使用上面的代码对 jira.releases table:
执行左连接SELECT b.*,c.releasedate from digitalpfatforms.issues_braze b
Left join jira.releases c
On b.version_id=c.versionid
有了这个,我得到了以下预期输出:
issueid | sprintid | sprintenddate | version_id | releasedate |
---|---|---|---|---|
1945 | 85 | 20/11/2021 | 45699 | 25/11/2021 |
1836 | 90 | 01/12/2021 | 54555 | 05/12/2021 |
1836 | 90 | 01/12/2021 | 54555 | 05/12/2021 |
2000 | 55 | 10/11/2021 | 56777 | 15/11/2021 |
2000 | 55 | 10/11/2021 | 56777 | 15/11/2021 |
2000 | 55 | 10/11/2021 | 56777 | 15/11/2021 |
根据这个输出,我需要计算 2 dense_rank()。超过 sprintenddate:
DENSE_RANK() OVER(ORDER BY b.sprintenddate DESC) AS "rank_sprint"
和另一个过度释放:
DENSE_RANK() OVER(ORDER BY c.releasedate DESC) AS "rank_release"
我的预期输出是:
issueid | sprintid | sprintenddate | version_id | releasedate | rank_sprint | rank_release |
---|---|---|---|---|---|---|
1945 | 85 | 20/11/2021 | 45699 | 25/11/2021 | 2 | 2 |
1836 | 90 | 01/12/2021 | 54555 | 05/12/2021 | 1 | 1 |
1836 | 90 | 01/12/2021 | 54555 | 05/12/2021 | 1 | 1 |
2000 | 55 | 10/11/2021 | 56777 | 15/11/2021 | 3 | 3 |
2000 | 55 | 10/11/2021 | 56777 | 15/11/2021 | 3 | 3 |
2000 | 55 | 10/11/2021 | 56777 | 15/11/2021 | 3 | 3 |
任何人都可以帮助我如何组合 SQL 查询,以便它执行连接并计算提到的 dense_rank?
谢谢
看起来您已经完成了所有工作。把所有的部分加在一起就可以了。
SELECT b.*,
c.releasedate,
DENSE_RANK() OVER(ORDER BY b.sprintenddate DESC) AS "rank_sprint",
DENSE_RANK() OVER(ORDER BY c.releasedate DESC) AS "rank_release"
from digitalpfatforms.issues_braze b
left join jira.releases c on b.version_id=c.versionid