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

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesOracle Development

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 Dev Shed Forums Sponsor:
  #1  
Old January 6th, 2004, 05:59 AM
zidane77 zidane77 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 1 zidane77 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Querly latest distinct values

Hi,

Sorry for this, I'm a newbie and I need help urgently:

I have three values from two tables to query: TABLE1.DATE, TABLE1.VALUE, TABLE2.STATUS

How do I query only the distinct values from TABLE1.VALUE and only the latest (based on the value of TABLE1.DATE)???

(TABLE2 and TABLE1 are related using a column called SITE_ID, where TABLE2.SITE_ID = TABLE1.SITE_ID)



Example:

TABLE1.DATE-----TABLE1.VALUE------TABLE2.STATUS
11/20/2003------------60--------------------1------
11/19/2003------------40--------------------0------
11/19/2003------------50--------------------1------
11/18/2003------------40--------------------0------
11/18/2003------------50--------------------1------
11/17/2003------------20--------------------0------

The query should return the following:

TABLE1.DATE-----TABLE1.VALUE------TABLE2.STATUS
11/20/2003------------60--------------------1------
11/19/2003------------50--------------------1------
11/19/2003------------40--------------------0------
11/17/2003------------20--------------------0------


Appreciate any help out there. Many, many thanks in advance!!!

Reply With Quote
  #2  
Old January 6th, 2004, 09:17 AM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 10
Your query look like that:

SELECT t1.date,t1.value, t2.status
FROM table1 t1, table2 t2
Where (date,value) in (SELECT max(date),value from table1 group by value)
and t1.date = t2.date
and t1.value = t2.value
/

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Querly latest distinct values

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 - 2013, Jelsoft Enterprises Ltd.

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