I'm working with Oracle 10G, but i have never used COLLECT to concatenate
Look, it is pretty simple, don't require any user-defined aggregate function, types, analytic functions.
SQL> SELECT dept.DEPARTMENT_NAME DEP, COLLECT (emp.LAST_NAME) LAST_NAMES FROM departments dept, employees emp WHERE dept.DEPARTMENT_ID = emp.DEPARTMENT_ID GROUP BY dept.DEPARTMENT_NAME; DEP LAST_NAMES ------------------------------ ------------------------------------------------- Administration SYSTPdOAhPUUuTY2R3kKsEORiAg==('Whalen') Marketing SYSTPdOAhPUUuTY2R3kKsEORiAg==('Hartstein', 'Fay')
Of course if need to write a query for some report in UI or for some data extract process you shoud use another technique, but if you use 10g and need to see or show to youre colleagues same concatenated data you can use this. Without any preparation, creating new objects and so on. Or, if you are 11g R2 user, then you just can use LISTAGG analytic function.
No comments:
Post a Comment