Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT MAX 1

Status
Not open for further replies.

Extension

Programmer
Nov 3, 2004
311
CA
Hi,

I'm trying to query a table in order to get the latest record with MAX(DATE)
I have 2 conditions before selecting the lastest record. I cannot use the SELECT MAX statement in my initial SELECT statement because I need to check the records against the 2 conditions before.


Code:
SELECT *
FROM PROFILES
WHERE ACTIVE = 1
AND PROFILE_TYPE = 'TEST'
ORDER BY DATE
 
SELECT A.*
FROM PROFILES AS A
WHERE A.ACTIVE = 1 AND A.PROFILE_TYPE = 'TEST'
AND A.DATE = (SELECT Max(B.DATE) FROM PROFILES AS B WHERE B.ACTIVE = 1 AND B.PROFILE_TYPE = 'TEST')

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top