Oracle spliced into a string in the result set (effective pro-test)

Data Sheet Description

CLASS_ID STUDENT_ID  STUDENT_NAME
101 1 Joe Smith
101 2 John Doe
102 1 Wang Wu
102 2 Zhao six

 

TO_CHAR method and use WM_CONCAT

SELECT
     WM_CONCAT(

              TO_CHAR(   

                     C.STUDENT_ID  ) 

                )   as    studentIDs

FROM

      T_CLASS  C

WHERE

     C.CLASS_ID = '101'

result:

   

studentIDs
1,2

 

Published 37 original articles · won praise 29 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_42755868/article/details/84645862