how to select max of mixed string/int column?

后端 未结 6 1232
没有蜡笔的小新
没有蜡笔的小新 2020-12-08 22:10

Lets say that I have a table which contains a column for invoice number, the data type is VARCHAR with mixed string/int values like:

invoice_number
*********         


        
6条回答
  •  温柔的废话
    2020-12-08 22:48

    After a while of searching I found the easiest solution to this.

    select MAX(CAST(REPLACE(REPLACE(invoice_number , 'HKL', ''), '', '') as int)) from invoice_header
    

提交回复
热议问题