有时候我们需要查询各组最新的一条记录,sql如下:
SELECT A.* FROM SPEC_RATE_ORIGIN A INNER JOIN (SELECT COMPANY_NAME,MAX(CREATE_TIME) AS "atime" FROM SPEC_RATE_ORIGIN group by COMPANY_NAME) B ON A.COMPANY_NAME = B.COMPANY_NAME AND A.CREATE_TIME = B."atime";
">
有时候我们需要查询各组最新的一条记录,sql如下:
SELECT A.* FROM SPEC_RATE_ORIGIN A INNER JOIN (SELECT COMPANY_NAME,MAX(CREATE_TIME) AS "atime" FROM SPEC_RATE_ORIGIN group by COMPANY_NAME) B ON A.COMPANY_NAME = B.COMPANY_NAME AND A.CREATE_TIME = B."atime";