Hi, guys I would like to write a query to return all records which has the closest date to the end of month. (Assume that date will be 6/30/2004)
| id | product_id | price | snapshot_date | +----+------------+--------+---------------+ | 1 | 1 | 99.95 | 2004-06-23 | | 2 | 1 | 99.74 | 2004-06-27 | * | 3 | 2 | 101.52 | 2004-06-25 | | 4 | 2 | 101.85 | 2004-07-01 | * | 5 | 3 | 100.00 | 2004-06-29 | | 6 | 3 | 100.50 | 2004-07-01 | * +----+------------+--------+---------------+ *if there is a tie, it always pick the one after the end of month The 2, 4, 6 entries shall be return by the query. Is this possible to write this in pure sql? Thanks in advance. Lam ________________________________________________________________ The best thing to hit the Internet in years - NetZero HiSpeed! Surf the Web up to FIVE TIMES FASTER! Only $14.95/ month -visit www.netzero.com to sign up today! -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]