Home > database >  Consult the SQL how to write
Consult the SQL how to write

Time:10-08

Table 1
Id FSRQ
1 2019/12/23
2 2020/5/8
1 2019/12/26
4 2020/1/2
1 2019/12/28

Table 2
Id ywrq GXRQ
1 2019/12/27 2019/12/27
2 2020/1/4 2020/1/4
3 2020/6/11 2020/6/11
4 2020/4/17 2020/4/17
5 2019/11/29 2019/11/29

Table 3
Id yyrq GXRQ
1 2020/5/14 2019/11/1
2 2020/4/15 2019/5/22
3 2021/9/6 2019/9/17
4 2021/7/5 2019/7/9
5 2020/4/2 2019/8/28


For the third FSRQ recently, check out the date after have ywrq (ywrqAnd table 2, table 3 largest updated date is greater than the system date of 60 days id

Consult the SQL how to write, the study

CodePudding user response:

Select * from
(select, Anderson d a.f SRQ, b.y WRQ, b.g XRQ, c.y yrq, c.g XRQ gxrq1 row_number () over (order by FSRQ desc) rn
The from tb1 a, tb2 b, tb3 c
Where Anderson, d=b.i d
And b.i d=c.i d
) t where rn<=3
And ywrqAnd gxrq> Sysdate + 60
And gxrq1 & gt; Sysdate + 60;

See if that fits your needs, your demand is not very understand

CodePudding user response:

Recently, three times with ROW_NUMER () OVER (PARTITION BY) the destructor of writing, his research will know, easy,
  • Related