COURSE_ID PRE_COURSE_ID OPERATOR -------------------------------------------- IT105 IT100 AND IT105 IT101 IT106 1T103 BM110 BM101 AND BM110 BM102 AND BM110 BM103 CC107 CC103 OR CC107 CC104 -------------------------------------------------------I am expecting the output to look like below:
COURSE_ID PRE_COURSE_ID ------------------------ IT105 IT100 and IT101 IT106 IT103 BM110 BM101,BM102 and BM103 CC107 CC103 OR CC104Here is my SQL script for this table CREATE TABLE test_Course ( course_ID VARCHAR(10) , pre_course_id VARCHAR(10) , operator VARCHAR(5) ); INSERT INTO test_Course ( course_ID , pre_course_id , operator ) VALUES ( 'IT105' , 'IT100' , 'and' ); INSERT INTO test_Course ( course_ID , pre_course_id , operator ) VALUES ( 'IT105' , 'IT101' , '' ); INSERT INTO test_Course ( course_ID , pre_course_id , operator ) VALUES ( 'IT106' , 'IT103' , '' ); INSERT INTO test_Course ( course_ID , pre_course_id , operator ) VALUES ( 'BM110' , 'BM101' , 'and' ); INSERT INTO test_Course ( course_ID , pre_course_id , operator ) VALUES ( 'BM110' , 'BM102' , 'and' ); INSERT INTO test_Course ( course_ID , pre_course_id , operator ) VALUES ( 'BM110' , 'BM103' , '' ); INSERT INTO test_Course ( course_ID , pre_course_id , operator ) VALUES ( 'CC107' , 'CC103' , 'or' ); INSERT INTO test_Course ( course_ID , pre_course_id , operator ) VALUES ( 'CC107' , 'CC104' , '' );