DB2

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDatabasesDB2

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old October 2nd, 2011, 11:28 PM
SQLSKR SQLSKR is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jun 2011
Posts: 3 SQLSKR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 10 m 56 sec
Reputation Power: 0
InnerJoin with multiple conditions

Table1

Column1 Column2 Column3 Column4
101 2001 3020 01-01-11
101 2001 3002 02-01-11
101 2001 3001 03-01-11
102 2002 3002 01-01-11

Table2
Column1 Column2 column3
20011 2001 200131
20012 2001 200132
20013 2001 200133

Table3
Column1 Column2
20011 Site
20012 Site
20013 Site

Query:
select T1.Column1, T2.Column3, T1.Column4, T3.Column2 from table1 T1 inner join table2 T2 on T1.column2 = T2.column2
inner join table2 T3 on T2.Column1 = T3.Column1
where T1.column2 = 2001

Result:
101 200131 01-01-11 Site
101 200131 02-01-11 Site
101 200131 03-01-11 Site
101 200132 01-01-11 Site
101 200132 02-01-11 Site
101 200132 03-01-11 Site
101 200133 01-01-11 Site
101 200133 02-01-11 Site
101 200133 03-01-11 Site

I want to get only the following rows:

101 200131 01-01-11 Site
101 200132 01-01-11 Site
101 200133 01-01-11 Site

I need to use max value of T1.Column3 in the inner join to get the expected result that I want.

Please Let me know how can I use multiple conditions in this case.

Reply With Quote
Reply

Viewing: Tutorialized ForumsDatabasesDB2 > InnerJoin with multiple conditions


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap