RSS Forums RSS

how do I nest a CASE statement in an INNER JOIN

Please support our Oracle advertiser: Programming Forums
Reply
Posts: 1
Reputation: bohil is an unknown quantity at this point 
Solved Threads: 0
bohil bohil is offline Offline
Newbie Poster

how do I nest a CASE statement in an INNER JOIN

  #1  
Nov 17th, 2008
Hello,

I am trying to nest some CASE statements into INNER JOINs (one CASE per INNER JOIN).

The current code is:
  1. SELECT
  2. a.zone, a.ifield, a.iwhse, a.idesc, a.iposition
  3. FROM schema.itable a
<---This is where I would like to place the INNER JOIN w/ CASE
  1. LEFT OUTER JOIN
  2. (
  3. SELECT
  4. x.icode, x.ikey, x.idesc, x.icurrent
  5. FROM schema.itablex
  6. ) b
  7. ON a.iwhse = b.icode
  8. AND a.ikey = b.ikey
  9. AND icurrent = 'true'
  10. LEFT OUTER JOIN
  11. etc. . . . .

Anyway, I really don't even know where to begin with the syntax (assuming it can be done). I've tried to do the implied INNER JOIN by leaving the INNER JOIN w/ case in this form:
  1. SELECT iitem, ikey
  2. CASE WHEN iitem IS NULL then 'Y'
  3. WHEN iitem = ' ' then 'Y'
  4. ELSE 'N"
  5. END
  6. FROM schema.itable
  7.  

And, I've also tried to spell out the INNER JOIN and put the CASE statement into the ON clause like this:
  1. INNER JOIN
  2. (
  3. SELECT iitem, ikey
  4. FROM schemai.TABLE
  5. WHERE icurrent = 'true'
  6. )
  7. ON
  8. CASE WHEN iitem IS NULL then 'Y'
  9. WHEN iitem = ' ' then 'Y'
  10. ELSE 'N"
  11. END
  12.  
. . . also tried with parens around the CASE statement.

I'm not only new to databases and SQL, but am also new to posting on forums for assistance. So, if there's any other info that would be helpful, please let me know.

Thanks!
Last edited by bohil : Nov 17th, 2008 at 10:44 am.
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Views: 1937 | Replies: 0 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 10:12 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC