| 
		
			| LISTAGG [message #573881] | Thu, 03 January 2013 16:44  |  
			| 
				
				|  | tgreen1 Messages: 13
 Registered: December 2012
 | Junior Member |  |  |  
	| I'm trying to use the LISTAGG function, but I keep getting an ORA-00937 error (not a single-group group function). I'm concatenating several columns into one, and that is what I want to LISTAGG on. Can anyone tell me what I'm doing wrong? See below. 
 select distinct COLUMN1, LISTAGG(upper('LABEL: ' || COLUMN2 || '-' || COLUMN3 || '.' || COLUMN4),';')
 WITHIN GROUP (ORDER BY COLUMN2) as COLUMN_NAME
 from DUMMY
 inner join DUMMY2 on  COLUMN1=COLUMN2
 
 Any suggestions would be appreciated.
 
 Thanks.
 |  
	|  |  | 
	|  | 
	|  | 
	|  | 
	|  | 
	|  | 
	|  | 
	|  | 
	| 
		
			| Re: LISTAGG - ORA-00937 [message #573944 is a reply to message #573937] | Fri, 04 January 2013 08:54   |  
			| 
				
				|  | tgreen1 Messages: 13
 Registered: December 2012
 | Junior Member |  |  |  
	| This is the revised code. Adding the "GROUP BY" as BlackSwan suggested did fix the ORA-00937 error. I'm now getting a ORA-01489 error. However, I think I will try to just LISTAGG on the value and see how that goes. 
 SELECT DISTINCT r.id                                                 USER_ID,
 r.first_last                                         USER_NAME,
 r.ROLE                                               ROLE,
 Listagg(Upper('PDD: '
 || p.role_id
 || '-'
 || p.parameter
 || '.'
 || p.value), ';')
 within GROUP (ORDER BY r.id, r.first_last, r.ROLE) AS
 p_responsibility
 FROM   itr_users r
 inner join app_user_security_map p
 ON r.id = p.user_id GROUP BY r.id, r.first_last, r.ROLE
 
 Thanks
 |  
	|  |  | 
	|  | 
	| 
		
			| Re: LISTAGG - ORA-00937 [message #573955 is a reply to message #573945] | Fri, 04 January 2013 09:34  |  
			| 
				
				|  | tgreen1 Messages: 13
 Registered: December 2012
 | Junior Member |  |  |  
	| This gave me desired results. 
 
 
SELECT DISTINCT r.id                                                 USER_ID, 
                r.first_last                                         USER_NAME, 
                r.ROLE                                               ROLE, 
                Upper('PDD: ' || p.role_id || '-' || p.parameter || '.' || LISTAGG(p.value,',') WITHIN GROUP (ORDER BY p.value)) 
                  AS p_responsibility 
FROM   itr_users r 
       inner join app_user_security_map p 
               ON r.id = p.user_id GROUP BY r.id, r.first_last, r.ROLE, p.role_id, p.parameter
 Thank each of you for your help.
 |  
	|  |  |