No question at this time
The DBA-Village forum
as RSS feed
Site StatisticsEver registered users | 48741 | Total active users | 1338 | Act. users last 24h | 6 | Act. users last hour | 0 | Registered user hits last week | 145 | Registered user hits last month | 435 |
|
Go up
Help with a SQL query
Subject: |
Help with a SQL query |
Author: |
S SPB, India |
Date: |
Jan 10, 2023, 05:00, 140 days ago |
Os info: |
Anything |
Oracle info: |
Anything |
Message: |
Hi All,
Need some SQL help!
I have two tables... one is having below data
tableA
Database_version Patch_release
---------------- --------------
12.1.0.2.220718 JUL_2022
19.16.0.0.220719 JUL_2022
12.2.0.1.220719 JUL_2022
tableB
DB_Name Description
---------- ------------
ABCD Database Jul 2022 Release Update : 12.1.0.2.220718
XYZ Database Jul 2022 Release Update : 19.16.0.0.220719
PQRS Database Jul 2022 Release Update : 12.2.0.1.220719
I want to search for TableA.Database_version in TableB and decode it to TableA.Patch_Release as below.
Kindly help with the query formation for this result?
DB_Name Patch_Release
-------- ----------------
ABCD JUL_2022
XYZ JUL_2022
PQRS JUL_2022
Thanks a lot!
|
Goto: |
Reply - Top of page |
If you think this item violates copyrights, please click here
Subject: |
Re: Help with a SQL query |
Author: |
Bruno Vroman, Belgium |
Date: |
Jan 10, 2023, 09:00, 139 days ago |
Score: |
       |
Message: |
Hello,
maybe somethiçng like this: (remark: try to provide the "CREATE TABLE" statements to facilitate a bit the work of people helping you)CREATE TABLE tablea AS
SELECT '12.1.0.2.220718' database_version, 'JUL_2022' patch_release FROM dual
UNION ALL SELECT '19.16.0.0.220719', 'JUL_2022' FROM dual
UNION ALL SELECT '12.2.0.1.220719', 'JUL_2022' FROM dual
;
CREATE TABLE tableb AS
SELECT 'ABCD' db_name, 'Database Jul 2022 Release Update : 12.1.0.2.220718' description FROM dual
UNION ALL SELECT 'XYZ', 'Database Jul 2022 Release Update : 19.16.0.0.220719' FROM dual
UNION ALL SELECT 'PQRS', 'Database Jul 2022 Release Update : 12.2.0.1.220719' FROM dual
;
SELECT b.db_name, a.patch_release
FROM tableb b
INNER JOIN tablea a
ON a.database_version = SUBSTR( b.description, INSTR( b.description, ' : ' ) + 3 )
; Best regards,
Bruno Vroman. |
Your rating?: |
This reply is Good Excellent |
Goto: |
Reply - Top of page |
If you think this item violates copyrights, please click here
Subject: |
Re: Help with a SQL query |
Author: |
Michel Cadot, France |
Date: |
Jan 10, 2023, 10:23, 139 days ago |
Score: |
       |
Message: |
Thanks Bruno for the test case.
Another solution:
SQL> SELECT b.db_name, a.patch_release
2 FROM tablea a, tableb b
3 WHERE REGEXP_LIKE(b.description, a.database_version)
4 /
DB_N PATCH_RE
---- --------
ABCD JUL_2022
XYZ JUL_2022
PQRS JUL_2022
3 rows selected.
Regards
Michel
|
Your rating?: |
This reply is Good Excellent |
Goto: |
Reply - Top of page |
If you think this item violates copyrights, please click here
|