SQL-ORDER BY DESC无法正确获取结果

问题描述

我正在尝试获取列的最大值,但是SQL查询不能完全响应。

这是我完整的查询

select batch_upload_id from 
 (select batch_upload_id from cor_branch_upload 
  order by BATCH_UPLOAD_ID desc) 
where rownum = 1

应该返回10但返回9

enter image description here

解决方法

尝试

select batch_upload_id from 
(select batch_upload_id 
 from cor_branch_upload 
 order by TO_NUMBER(BATCH_UPLOAD_ID) desc) 
where rownum = 1