sql 条件查询多条,只取最近一条

-- sql latestRecord
select * from tableName o
WHERE o.c_jjbm=''
order by d_drrq desc LIMIT 1
--oracle 写法
SELECT t.* from
(SELECT *
  FROM tableName 
  WHERE C_JJBM = ''
  ORDER by D_DRRQ desc
) t WHERE rownum = 1

 

你可能感兴趣的:(sql)