0

Possible Duplicate:
Is there an Oracle SQL query that aggregates multiple rows into one row?

I have a table (Employee).

Employee

ID   Name   Salary  

1    Steve  10000

2    Buck   15000

3    Dan    10000 

4    Dave   10000

I need to return all employee names who have the salary of $10000, employee names are delimited by Plus signs – including one on the beginning and end. I can do this using a cursor and add all the employee names iterate through the cursor. But is there a way to return this using a single query? In this above example i need the result as +Steve+Dan+Dave+

Community
  • 1
  • 1
user1430989
  • 525
  • 2
  • 6
  • 15

1 Answers1

0

Have a look on string aggregation functions.

For example in Oracle 11g Release 2, you can do somthing like :

SELECT CONCAT(CONCAT('+', LISTAGG(Employee.Name, '+')), '+') FROM Employee WHERE Salary >= 10000
berty
  • 2,178
  • 11
  • 19