Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Query Help Needed

Query Help Needed

From: GZ <gz_at_yahoo.com>
Date: Tue, 04 Sep 2001 21:14:15 -0400
Message-ID: <3B957C66.C56AEB6B@yahoo.com>


I would like to know if there is a way in SQL to select from rows of similar data and to limit the result into one row and concatenating the results from many columns into one column. ie show Jones as belonging to more than one department.(No primary key in table)

Emp Table



Name Address Dept
Jones     10 Main St     Accounting
Jones     10 Main St     Sales
Jones     10 Main St     IT
Smith     12 King St     Marketing

Query returning:

Jones     10 Main St     Accounting/Sales/IT
Smith     12 King St     Marketing


--------------------------------------------

Also how would I only return rows from a table that have non-matching data in a series of columns.(is there an easy way to do a comparison between many columns? ie In this case, return only people who have changed departments.

Emp Table


Name 1996 1997 1998 1999

Hart      Acct       Acct     Acct      Acct
Smith    Acct       Mktg     Sales     IT
Jones    HR         HR         Mktg     Mktg
Johnson HR         HR         HR       HR

Query returning:

Smith     Acct        Mktg      Sales     IT
Jones     HR          HR          Mktg     Mktg


Any help would be much appreciated.

Thanks,

Greg Received on Tue Sep 04 2001 - 20:14:15 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US