SunQuest
 
           Database Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesDatabase Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old July 4th, 2006, 01:00 AM
stevep stevep is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 1 stevep User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 35 sec
Reputation Power: 0
SQL SELECT Max date and = id

I am trying to select from a tbl the LATEST date and also where the ID is = 'x'.

What seems to be wrong with this? I am sooooo lost in SQL.

Thanks
heaps

SELECT tblPTSENDams.damName, tblPTSENDamData.maxCap, tblPTSENDamData.relLevel, tblPTSENDams.purpose, tblPTSENDamData.currentCap,
tblPTSENDamData.dateLastMeasured, tblPTSENDams.damID, tblPTSENDamData.damID AS Expr1
FROM tblPTSENDamData INNER JOIN
tblPTSENDams ON tblPTSENDamData.damID = tblPTSENDams.damID
WHERE (tblPTSENDamData.dateLastMeasured =
(SELECT MAX(dateLastMeasured) AS Expr1
FROM tblPTSENDamData AS tblPTSENDamData_1
WHERE tblPTSENDAMData.damID = 4))

Reply With Quote
  #2  
Old August 2nd, 2006, 04:47 AM
emielbon emielbon is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 1 emielbon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 59 sec
Reputation Power: 0
take a look at this :

http://sqlteam.com/forums/topic.asp?TOPIC_ID=69648


greets,
Emiel

Quote:
Originally Posted by stevep
I am trying to select from a tbl the LATEST date and also where the ID is = 'x'.

What seems to be wrong with this? I am sooooo lost in SQL.

Thanks
heaps

SELECT tblPTSENDams.damName, tblPTSENDamData.maxCap, tblPTSENDamData.relLevel, tblPTSENDams.purpose, tblPTSENDamData.currentCap,
tblPTSENDamData.dateLastMeasured, tblPTSENDams.damID, tblPTSENDamData.damID AS Expr1
FROM tblPTSENDamData INNER JOIN
tblPTSENDams ON tblPTSENDamData.damID = tblPTSENDams.damID
WHERE (tblPTSENDamData.dateLastMeasured =
(SELECT MAX(dateLastMeasured) AS Expr1
FROM tblPTSENDamData AS tblPTSENDamData_1
WHERE tblPTSENDAMData.damID = 4))

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesDatabase Development > SQL SELECT Max date and = id


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway