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

Home -> Community -> Mailing Lists -> Oracle-L -> Re: SQL Query

Re: SQL Query

From: sundeep maini <sundeep_maini_at_yahoo.com>
Date: Thu, 25 Sep 2003 13:59:43 -0800
Message-ID: <F001.005D114E.20030925135943@fatcity.com>


Mike,

Just wanted to supplement your example with another one from my environment:

SELECT c.customer_id

      ,customer_name
      ,utils.code_table_to_string(CAST( MULTISET(
        SELECT distinct dlr_dealer_code
          FROM dealer_customers dc
		       ,dlr_dealer_master_t
         WHERE dc.customer_id = dc_in.customer_id
		   AND dlr_dealer_id = dc.dealer_id
		 ORDER BY dlr_dealer_code
		) AS code_table_t
	  )) spans_these_dealers
 FROM customers c
     ,(
       SELECT customer_id
	     FROM dealer_customers 
		GROUP BY customer_id
		HAVING COUNT(distinct dealer_id) > 1
	  ) dc_in

WHERE dc_in.customer_id = c.customer_id;

Does eseentially the same thing. In this case it concatenates the dealer_codes per customer (identifies customers spanning multiple dealers) on the same row. Here is a sample of the output:

2969473096	Mountain Enterprises Inc	D100,D470,D480
2969473121	K C Construction	B010,B150,B190
2969473195	GOODFELLOW BROS	H140,H330

Sundeep Maini
Consultant
Currently on Assignement at Caterpillar Peoria sundeep_maini_k_at_cat.com



Do you Yahoo!?
The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: sundeep maini
  INET: sundeep_maini_at_yahoo.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Thu Sep 25 2003 - 16:59:43 CDT

Original text of this message

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