[ad_1]
We have a table that stores Name/value pairs, one record to store a Host name and another to store a port number.
Instead of returning two rows, I’d like to return one row with two columns. I could accomplish it as follows but I have several columns to return and I suspect that a PIVOT may yield simpler SQL in the end.
SELECT
(
SELECT
CCD.DISPL_CTGRY_CD AS EMAIL_HOST
FROM FDS_MAINT.CONFGRTN_CTGRY_DTL CCD
WHERE CCD.CONFGRTN_CTGRY_ID = 56
AND CCD.CONFGRTN_CTGRY_CD = 'HOST'
) HOST,
(
SELECT
CCD.DISPL_CTGRY_CD AS EMAIL_HOST
FROM FDS_MAINT.CONFGRTN_CTGRY_DTL CCD
WHERE CCD.CONFGRTN_CTGRY_ID = 56
AND CCD.CONFGRTN_CTGRY_CD = 'PORT'
) PORT
FROM DUAL
Could you please help me accomplish this SQL to get the following results using a PIVOT function?
HOST | PORT |
---|---|
testapp.silver.com | 25 |
I’m using Oracle 19.
Thanks!
[ad_2]