SQL Question
The objective of this task is to display the instructor ('IN') names in one column for each section separated by a semicolon. (all the outputs(columns) are from same tables )
SELECT
section_id,
temp_person_name
FROM
stan.section_person
WHERE
rnr_role_code = 'IN';
The code will have this output.
SECTION_ID TEMP_PERSON_NAME
---------- --------------------------------------------------------------------------------------------------------------------------------
93 Herscher, Joshua
93 Vankanegan, Steve
95 Peyser, Michael
96 Hoggard, Zabrina
96 Simmons, Ghia
60 Esirgen, Gokhan
60 Griffith, Ryan
-- Expected/Desired Result
/*
60 Esirgen, Gokhan; Esirgen, Gokhan
93 Herscher, Joshua; Herscher, Joshua
95 Peyser, Michael
96 Hoggard, Zabrina; Simmons, Ghia
*/
My code is this:
SELECT section_id,
temp_person_name = STUFF( // this is line 10
(SELECT ',' + temp_person_name
FROM stan.section_person
WHERE rnr_role_code = 'IN'
FOR XML PATH('')), 1, 1, ''
)
FROM stan.section_person
GROUP BY section_id;
and the output error is this:
ORA-00923: FROM keyword not found where expected
00923. 00000 - "FROM keyword not found where expected"
*Cause:
*Action:
Error at Line: 10 Column: 25