Merge on tables [message #640745] |
Tue, 04 August 2015 13:33 |
|
vasudevaviswa
Messages: 53 Registered: August 2015 Location: US
|
Member |
|
|
Hi all,
I have two tables
CREATE table W_S_SCORE
(
F_CODE Varchar2(3),
E_SCORES varchar2(2)
S_SCORE varchar2(2)
);
INSERT INTO W_S_SCOREvalues ('12A', '08','01');
INSERT INTO W_S_SCOREvalues ('12A', '09','04');
INSERT INTO W_S_SCOREvalues ('12A', '10','05');
INSERT INTO W_S_SCOREvalues ('12A', '07','05');
INSERT INTO W_S_SCOREvalues ('12C', '08','01');
Table 2 :
CREATE TABLE A_STUD
(
l_code varchar2(6),
f_code varchar2(3),
E_SCORE VARCHAR2(2),
S_SCORES VARCHAR2(2)
);
INSERT INTO A_STUD (l_code ,f_code ,E_SCORE) VALUES ('2028','12A','08');
INSERT INTO A_STUD (l_code ,f_code ,E_SCORE) VALUES ('2029','12C','19');
INSERT INTO A_STUD (l_code ,f_code ,E_SCORE) VALUES ('2030','12C','20');
INSERT INTO A_STUD (l_code ,f_code ,E_SCORE) VALUES ('2031','12C','10');
INSERT INTO A_STUD (l_code ,f_code ,E_SCORE) VALUES ('2032','12A','08');
INSERT INTO A_STUD (l_code ,f_code ,E_SCORE) VALUES ('2037','12C','07');
INSERT INTO A_STUD (l_code ,f_code ,E_SCORE) VALUES ('2038','12C','10');
TABLE HAS DATA AS FOLLOWS:
l_code f_code E_sCORES S_SCORE
---------------------------------------------------------
2028 12A 08
2029 12C 19
---
---
---
nOW REQUIRED O/P SHOULD BE , S_SCORE COLUMN SHOULD UPDATE BASED ON E_SCORES DATA
l_code f_code E_sCORES S_SCORE
---------------------------------------------------------
2028 SCOTT 08 01
2029 GARMIN 19 13
{CODE}
If, In A_STUD table S_SCORE is missing then it should retrieve S_SCORE value automatically from W_S_SCORE table based on the E_SCORE in A_STUD table.
Thanks,
Vasudev
|
|
|
|
|
|
|
|
|
|
|
|
Re: Merge on tables [message #640761 is a reply to message #640757] |
Tue, 04 August 2015 16:19 |
|
vasudevaviswa
Messages: 53 Registered: August 2015 Location: US
|
Member |
|
|
F_CODE has different codes. 10C,12A,12B,10C,10B.. etc.. are F_CODES... these are coming from W_S_SCORE table.
I have posted different F_CODE here..
Let me know what other information you required...
Posted the table structure and some of the data.. which is existed in the given 2 tables..
[Updated on: Tue, 04 August 2015 16:21] Report message to a moderator
|
|
|
|
|
|