字段1(类型varchar) 字段2(类型varchar) 字段3(blob) 字段4(datetime)
A1 B001 BLOB 2009-1-1
A2 B001 BLOB 2010-1-1
A3 B001 BLOB 2011-1-1
现在我要求最大时间那一条数据,SQL语句该怎么写?
A3 B001 BLOB(图片) 2011-1-1
------解决方案--------------------
SELECT *
FROM (SELECT G.*,
ROW_NUMBER() OVER(PARTITION BY 字段2 ORDER BY 字段4 DESC) ROWNUN
FROM table_name G) H
WHERE H.ROWNUN = 1