1. Actual requirements: Description: in the preceding table, a student has multiple courses and scores, and now wants to have an SQL statement that combines the course name and score for display, www.2cto.com: all the courses and scores of this student are represented in one field, it includes all the course names and exam scores. 2. To solve the problem, you can use the function creation method to merge the two fields. However, this is too troublesome, because Oracle10g is used, the wmsys function can be used. wm_concat. 3. Solution SQL: the first step is to write a view view_ly_sjdxpt_jwcj and merge the two fields with the SQL code as select www.2cto.com xh hm and kcmc | zscj as kc_cj from dcuser. ly_xs_bzks_cjb B; Result: Write another view in step 2, and use wmsys. wm_concat () Merge the KC_CJ field into the SQL code: createorreplaceview_ly_sjdxpt_1_cj_kz as select hm, wmsys. wm_concat (kc_cj) as kccj from view_ly_sjdxpt_jwcj groupby hm; Result: You can use the SQL code: selectdistinct 'educational score 'dxlb, xh hm, (select lxdh fromdcuser. LY_XS_BZKS_XSJBXX where xh = B. xh) sjhm, to_char (sysdate, 'yyyymmddhh24mis') crsj, www.2cto.com xm | 'Dear Student, your score for each subject this semester is as follows:' | c. kccj as nr, ''bz,'' fssj fromdcuser. ly_xs_bzks_cjb B leftouterjoin dcuser_kz.view_ly_sjdxpt_1_cj_kz c on B. xh = c. hm result:
From the column wdh226