By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,197 Members | 988 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

How to writ function in postgres?

P: 2
Plz can any one help me to write function in postgres

i have a table with two columns
for example student class and student name

the table Data is like this
STU_class Name
1 Ann
2 JAck
3 Dickson
1 Donald

but the report i need is in the following format

Class Name
1 Ann,Donald
2 JacK
3 Dickson

can anyone help me to generate this report

Thanks in advance
Apr 4 '08 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 700
Plz can any one help me to write function in postgres

i have a table with two columns
for example student class and student name

the table Data is like this
STU_class Name
1 Ann
2 JAck
3 Dickson
1 Donald

but the report i need is in the following format

Class Name
1 Ann,Donald
2 JacK
3 Dickson

can anyone help me to generate this report

Thanks in advance
Suppose table name is test, i think it is the solution
Expand|Select|Wrap|Line Numbers
  1. select distinct  i as class, array_to_string((array(select j from test where i=k.i)),',') as name from test k;
  2.  
Apr 4 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.