I have 2 tables that I am trying to extract info from it. This is a sample of the tables below as these are large tables. I want the description ON TABLE 1 to be on a column KEY_EVENT BY LOOKING into table 2 and the only common column is an APP column. but error has been coming subquery can not return more than one row.
TABLE 1
APP LANGUAGE DESCRIPTION
195 12 Involved person
195 27 Involved person
196 1 Involvert legemiddel
196 2 Involved drug
196 3 Involverad lakemedel
196 4 Involveret l?gemiddel
196 12 Involved drug
196 27 Involved drug
197 1 Eksponeringsverdier
197 2 Exposure values
197 3 Exponeringsvarden
197 4 Eksponeringsv?rdier
197 12 Exposure values
197 27 Exposure values
198 1 Indikatorer
198 2 Indicators
198 3 Indikatorer
198 4 Indikatorer
198 12 Indicators
198 27 Indicators
199 1 Generell klassifisering
199 2 General classification
199 3 Generell klassificering
199 4 Generel klassifisering
199 12 General classification
199 27 General classification
TABLE 2
TRANS APP
1 195
2 195
3 196
4 196
5 196
6 196
7 196
8 196
9 197
10 197
11 197
12 197
13 197
14 197
15 198
16 198
17 198
18 198
19 198
20 198
21 199
22 199
23 199
24 199
25 199
26 199
In addition, I want to use - I want to concatenate the DESCRIPTION USING LISTAGG if we have common appl with multiple description
SELECT SELECT NVL(TO_CHAR(TRANS.ID), 'NULL') AS ID
, 'HEADER'
,NVL(TO_CHAR((SELECT L_APP.DESCRIPTION
FROM L_APP L_APP
WHERE EXISTS ( SELECT 1 FROM TRANS WHERE L_APP.APP = TRANS.APP AND LANGUAGE = 2
)
)), 'NULL') AS KEY_EVENT