Home » SQL & PL/SQL » SQL & PL/SQL » Quary Required ., ( Column to row )
Quary Required ., ( Column to row ) [message #270478] Thu, 27 September 2007 03:02 Go to next message
rajas_k
Messages: 1
Registered: September 2007
Location: Hyderabad
Junior Member

Hi
I have 2 tables called :

PROGRAMMANAGEMENT & PROGRAMACCOUNTTYPES ., where for each program there will be several qualified / non qualified account types will be there ., the flag will be set in the table PROGRAMACCOUNTTYPES .,

My query is , i want to retrive all the fields of PROGRAMMANAGEMENT table along with comma separated fields of
PROGRAMACCOUNTTYPES for that particulor program in a single row.

PROGRAMMANAGEMENT Table contains the fields :

programid
programname
programdescription
programgroupid
programmgmtstatus
fromdate
todate

and PROGRAMACCOUNTTYPES contains the fileds :
prgaccounttypeid
accounttypeid
programid
qualifiedstatus


Output should be like :

Select (programid,programname,programdescription,programgroupid,
programmgmtstatus,fromdate,todate,||'','||prgaccounttypeid||','||
accounttypeid ||','||qualifiedstatus )

where qualifiedstatus = 1
and programid = X
union
Select (programid,programname,programdescription,programgroupid,
programmgmtstatus,fromdate,todate,||'','||prgaccounttypeid||','||
accounttypeid ||','||qualifiedstatus )

where qualifiedstatus = 0
and programid = X;

There are the multiple qualified /unqualified accounts for each programid.


Can any Once plese help me out in this .,
Re: Quary Required ., ( Column to row ) [message #270483 is a reply to message #270478] Thu, 27 September 2007 03:14 Go to previous messageGo to next message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
Please read Orafaq Forum Guide pay particualr attention to the section on 'How to get a quick answer to your post. Part extra special attention to the very 1st bullet point in that section.
(Also have a look at the section on formatting your posts)
Thanks
Re: Quary Required ., ( Column to row ) [message #270747 is a reply to message #270478] Thu, 27 September 2007 23:13 Go to previous message
SnippetyJoe
Messages: 63
Registered: March 2007
Location: Toronto, Canada
Member

SQL Snippets: SQL Techniques Tutorials - Rows to String

Previous Topic: PL SQL - In Operator Issue
Next Topic: using a result of subquery as a column name
Goto Forum:
  


Current Time: Mon Dec 05 03:07:27 CST 2016

Total time taken to generate the page: 0.24382 seconds