有时候需要获取数据库表中的一个的字段值里面的最大的值,下面分别用sql和hql都可以实现:
Sql代码
select max(to_number(substr(列名,前缀长度))) maxnum from 表名
Hql代码
(不需要转型 )selelct max(SUBSTRING(对象.属性名,前缀长度)) from 对象,
(不需要转型 )selelct max( CAST(SUBSTRING(对象.属性名,前缀长度),integer)) from 对象
Sql代码
select max(to_number(substr(列名,前缀长度))) maxnum from 表名
Hql代码
(不需要转型 )selelct max(SUBSTRING(对象.属性名,前缀长度)) from 对象,
(不需要转型 )selelct max( CAST(SUBSTRING(对象.属性名,前缀长度),integer)) from 对象