|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
!! Help with query: Where Date = MAX(Date)
From: Graham Cossey (graham
cossey.plus.com)
Date: Fri Feb 04 2005 - 08:19:47 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Could someone please offer a little help.
I have a table like:
Year, Month, Start_date
2004 10 20041102
2004 11 20041203
2004 12 20050104
2005 01 20050204
2005 02 20050303
I need to get the latest Year,Month for a given date, so for example today
(20050204) I should retrieve 2005,01.
As I'm using 4.0.20 I can't use subqueries so how can I create a query that
does this?
SELECT year, month
FROM `dc_months`
WHERE start_date = (SELECT MAX(start_date)
from dc_months
where start_date <= '20050204')
Any help much appreciated
Graham
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]