Oracle-SQL查询以获取已从String转换为Integer的列的最大值 [英] Oracle-SQL Query to obtain the maximum value of a column that has been converted from String to Integer

查看:324
本文介绍了Oracle-SQL查询以获取已从String转换为Integer的列的最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我数据库的一个表中,有一个varchar2列,该列主要由数字组成.现在,我想接收该列的NUMERICAL最大值,而忽略非数值. 我怎么做? 谢谢.

In a table within my database there is a varchar2 column that mostly consists of numbers. Now I want to receive the NUMERICAL maximum of that column, ignoring non-numerical values. How do I do that? Thank you.

推荐答案

SQL> select * from t;

X                                                                               
----------                                                                      
1234                                                                            
836                                                                             
836AA%%$$                                                                       
BBcdfrg                                                                         
12099                                                                           

SQL> select max(to_number(x)) from t
  2  where trim(translate(x,'0123456789',' ')) is null
  3  /

MAX(TO_NUMBER(X))                                                               
-----------------                                                               
            12099       

这篇关于Oracle-SQL查询以获取已从String转换为Integer的列的最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆