Home > database >  About the two tables of contents of synthetic view
About the two tables of contents of synthetic view

Time:09-22

There are two table

Table a
IYEAR IT IMONTH SFCODE IMONERY
2017 1005 10051107091 643014.5298
2017 1005 10051107091 55.5555
2017 1005 10051107091 267491.9091
2018 1005 10051107091 1548.718
11 10051107091 2017 1005 45122.62957
2017 1005 10051107091 29296.3187
Table b
IYEAR IDEP IMONTH SFCODE IJX2
2018 1005 10051107091 7800
2018 1005 3 10051107091 600
2018 1005 10051107091 30000

I would now like to
Put the two tables in view to
IYEAR IDEP IMONTH SFCODE IJX2 IMONERY
View to four fields and two targets before the red field
If the former four fields exactly equal to red field data in a column, otherwise no field let her empty
Results:

Who said this view how to write?

CodePudding user response:

 
The select IYEAR, IT, IMONTH, SFCODE, 0 IJX2, IMONERY from A
Union all
Select IYEAR, IDEP, IMONTH, SFCODE IJX2, 0 IMONERY from B

CodePudding user response:

 
The select NVL (Anderson, YEAR, b.I YEAR) as IYEAR, NVL (a. IT, b. IT) as IT and NVL (a. IMONTH, b. IMONTH) as IMONTH, NVL (a. SFCODE, b. SFCODE) as SFCODE, b.I JX2, Anderson, MONERY
From a
Full join on b (Anderson, YEAR=b.I YEAR and Anderson, T=b.I Tand Anderson, the MONTH=b.I MONTH and a.S FCODE=b.S FCODE)

CodePudding user response:

 
The select NVL (Anderson, YEAR, b.I YEAR) as IYEAR, NVL (Anderson, T, b.I T) as IT, NVL (Anderson, the MONTH, b.I MONTH) as IMONTH, NVL (a.S FCODE, b.S FCODE) as SFCODE, b.I JX2, Anderson, MONERY
From a
Full join on b (Anderson, YEAR=b.I YEAR and Anderson, T=b.I Tand Anderson, the MONTH=b.I MONTH and a.S FCODE=b.S FCODE)
  • Related