DBAsupport.com Forums - Powered by vBulletin
Results 1 to 10 of 11

Thread: Neophyte: sub-select returning multpile rows

Threaded View

  1. #6
    Join Date
    Apr 2003
    Posts
    20
    I am back...
    The reason I think the previous suggestion won't work for the full query is because I actually have to pull multiple values from the enumval.value field in the complete query. I didn't post the complete query here before for a few reasons, 1. It's alot to post and 2. well to be frank, I'm rather embarassed by my lack of knowledge in what has become my job function, 3. I was trying not to be to huge of a pain.
    But here it goes:
    Code:
    SELECT a.c1, '|',
    	   b.mod_date, '|',
    	   f.curr_status, '|',
    	   a.c8, '|',
    	   a.c536870913, '|',
    	   a.c536870914, '|',
    	   a.c536870916, '|',
    	   a.c536870919, '|',
    	   c.start_date, '|',
    	   d.expire_date, '|',
    	   a.c536870922, '|',
    	   a.c536870923, '|',
    	   a.c536870924, '|',
    	   a.c536870925, '|',
    	   a.c536871105, '|',
    	   a.c536871106, '|',
    	   a.c536871107, '|',
    	   a.c536871108, '|',
    	   a.c536871109, '|',
    	   a.c536871111, '|',
    	   a.c536871112, '|',
    	   a.c536871113, '|',
    	   g.competitor_co, '|',
    	   h.us_citizen, '|',
    	   i.perma_res, '|',
    	   a.c536871117, '|',
    	   e.resident_expire
    FROM T215 a,
    /* data is stored in the DB as unix Epoc */ 
    	 (SELECT TO_CHAR(TO_DATE('01-JAN-1970','DD-MON-YYYY') + c6/86400
    	   ,'MM-DD-YYYY') mod_date FROM T215) b, 
    	 (SELECT TO_CHAR(TO_DATE('01-JAN-1970','DD-MON-YYYY') + c536870920/86400 
    	   ,'MM-DD-YYYY') start_date FROM T215) c,
    	 (SELECT TO_CHAR(TO_DATE('01-JAN-1970','DD-MON-YYYY') + c536870921/86400 
    	   ,'MM-DD-YYYY') expire_date FROM T215) d,
    	 (SELECT TO_CHAR(TO_DATE('01-JAN-1970','DD-MON-YYYY') + c536871118/86400 
    	   ,'MM-DD-YYYY') resident_expire FROM T215) e,
    
    	 (SELECT enumval.value curr_status FROM FIELD_ENUM_VALUES enumval, T215 status 
    	 	  	  WHERE enumval.schemaid = 215
    			  		 AND enumval.fieldid = 7
    					 	 AND enumval.enumid = status.c7) f,
       	 (SELECT enumval.value competitor_co FROM FIELD_ENUM_VALUES enumval, T215 status 
    	 	  	  WHERE enumval.schemaid = 215
    			  		 AND enumval.fieldid = 7
    					 	 AND enumval.enumid = status.c536871114) g,
       	 (SELECT enumval.value us_citizen FROM FIELD_ENUM_VALUES enumval, T215 status 
    	 	  	  WHERE enumval.schemaid = 215
    			  		 AND enumval.fieldid = 7
    					 	 AND enumval.enumid = status.c536871115) h,
       	 (SELECT enumval.value perma_res FROM FIELD_ENUM_VALUES enumval, T215 status 
    	 	  	  WHERE enumval.schemaid = 215
    			  		 AND enumval.fieldid = 7
    					 	 AND enumval.enumid = status.c536871116) i
    I know this is a mess, but I'm trying to gain an understanding so I can A: Make it work, B: work as effiecently as possible and C: learn something.

    I'm right now breaking it down to just a few fields at a time to try to rework this from the ground up to see if I can discover my errors.
    Any input and/or suggestions are greatly appreciated.

    Mark
    Last edited by marknel; 11-03-2003 at 03:05 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width