Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old April 4th, 2008, 11:21 AM
Newbie
 
Join Date: Apr 2008
Location: India
Age: 24
Posts: 2
Default How to writ function in postgres?

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
Reply
  #2  
Old April 4th, 2008, 03:16 PM
Moderator
 
Join Date: Dec 2006
Posts: 250
Default

Quote:
Originally Posted by annielucinda
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.  
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles