Useful shortcuts for vi editor

Showing posts with label listagg. Show all posts
Showing posts with label listagg. Show all posts

Tuesday 21 March 2017

LISTAGG examples

SQL>
select LISTAGG (last_name, ', ')  WITHIN GROUP (order by last_name)
from employees

SQL>
select LISTAGG (first_name || ' ' || last_name, ', ') WITHIN GROUP (order by first_name)
from employees

SQL>
select LISTAGG (first_name || ' ' || salary, ', ') WITHIN GROUP (order by salary desc)
from employees

SQL>
select LISTAGG (first_name || ' ' || salary || ' ' || NVL2(commission_pct, commission_pct, '0'), ', ') WITHIN GROUP (order by salary desc)
from employees