У меня есть это утверждение, которое сочетает в себе несколько строк в один, а затем выводит его так, как мне нужны данные:
SELECT COURSES_ID, REQUISITE_TYPE_TITLE
, RTRIM
( xmlagg (xmlelement (c, CONDITION_TITLE || '' || REQ_TEXT || '' ) order by ORDER_NUM).extract ('//text()')
, ',' ) AS REQTexts
FROM COS_REQUISITES
WHERE COURSES_ID = '1175'
AND REQUISITE_TYPE_TITLE != 'Corequisite'
GROUP BY COURSES_ID, REQUISITE_TYPE_TITLE;
Результат:
╔═══════════╦════════════╦═════════════════════════════════════╦═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║ ORDER_NUM ║ COURSES_ID ║ REQUISITE_TYPE_TITLE ║ REQ_TEXT ║
╠═══════════╬════════════╬═════════════════════════════════════╬═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╣
║ 1 ║ 1175 ║ Limitation on Enrollment ║ With minimum grade of "C" ║
║ 2 ║ 1175 ║ Advisory on Recommended Preparation ║ MATH 200 or equivalent college course with "C" or better or equivalent college course with "C" or better or MATH 205 or equivalent college course with "C" or better or or equivalent college course with "C" or better or equivalent college course with "C" or better ║
╚═══════════╩════════════╩═════════════════════════════════════╩═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝
Структура:
╔═══════════╦════════════╦═══════════╦═════════════════════════════════════╦══════════════════════════════════════════════════════════╗
║ ORDER_NUM ║ COURSES_ID ║ CONDITION ║ REQUISITE_TYPE_TITLE ║ REQ_TEXT ║
╠═══════════╬════════════╬═══════════╬═════════════════════════════════════╬══════════════════════════════════════════════════════════╣
║ 1164 ║ 1175 ║ ║ Advisory on Recommended Preparation ║ MATH 200 or equivalent college course with "C" or better ║
║ 1165 ║ 1175 ║ ║ Advisory on Recommended Preparation ║ or equivalent college course with "C" or better ║
║ 1166 ║ 1175 ║ or ║ Advisory on Recommended Preparation ║ MATH 205 or equivalent college course with "C" or better ║
║ 1167 ║ 1175 ║ or ║ Advisory on Recommended Preparation ║ or equivalent college course with "C" or better ║
║ 1168 ║ 1175 ║ ║ Advisory on Recommended Preparation ║ or equivalent college course with "C" or better ║
║ 1169 ║ 1175 ║ ║ Limitation on Enrollment ║ With minimum grade of "C" ║
╚═══════════╩════════════╩═══════════╩═════════════════════════════════════╩══════════════════════════════════════════════════════════╝
Требуется результат:
╔═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║ Advisory on Recommended Preparation MATH 200 or equivalent college course with "C" or better or equivalent college course with "C" or better or MATH 205 or equivalent college course with "C" or better or equivalent college course with "C" or better or equivalent college course with "C" or better Limitation on Enrollment With minimum grade of "C" ║
╚═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝
Я пытаюсь избежать Необходимость поставить это в таблицу TEMP или несколько представлений, которые выводят это в один раздел.
Я знаю, что у него есть плохие данные, но мне сказали мусор, мусор. Любая помощь была бы очень ценится.
даже с Listagg, который не позволяет отличить, насколько я могу сказать:
Выбрать Courses_id, listagg (requisite_type_title || '' || Соединение_title || '' || Req_text, '') внутри группы (заказ Oudder_num) как заголовок от COS_REQUISITES Где courses_id = '1175' Группа Courses_id;
Результат:
╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║ TITLE ║
╠════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╣
║ Advisory on Recommended Preparation MATH 200 or equivalent college course with "C" or better Advisory on Recommended Preparation or equivalent college course with "C" or better Advisory on Recommended Preparation or MATH 205 or equivalent college course with "C" or better Advisory on Recommended Preparation or or equivalent college course with "C" or better Advisory on Recommended Preparation or equivalent college course with "C" or better Limitation on Enrollment With minimum grade of "C" ║
╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝
Обратите внимание на Requisite_type_title повторяет, я только хочу, чтобы он появился один раз, как и желаемый результат. Я не могу изменить таблицу, чтобы они были нулевыми из-за этого, это таблица динамически загружается и обновляется кем-то еще в день.