SOS: SQL query - GROUP BY

iosoft

PC enthusiast since MS DOS 5
Skilled
Table -

UName UType
------- -------
Sam Admin
John MOD
Smith MOD
Ayan User
MaxAxe User
Udit User

I need a single query to use GROUPING so that the output looks like this -
UType "Users"
------- -------
Admin : Sam,
MOD : John, Smith,
User : Ayan, MaxAxe, Udit,
 
whatsinaname said:
create table <output_table_name> select UType,GROUP_CONCAT(UName) as Users from <input_table_name> group by UType;

GROUP_CONCAT is a function present in MySQL only, right? :unsure:

Which database are you using? I am assuming Oracle and posting some links.

Please check these links.

Halis way: Oracle group_concat() updated (again)
Oracle: Oracle release 10g - String aggregation: Oracle equivalent for a MySQL 'GROUP_CONCAT()'

OraFAQ Forum: SQL & PL/SQL => Hi, problem in selecting data

http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2196162600402

Increase code reuse with Oracle user-defined aggregate functions

Ask Tom "Function to concatenate output"
 
Back
Top