How to get max value of column type integer stored as type text in sqlite table

天涯浪子 提交于 2019-12-12 02:17:13

问题


I want to get MAX value of one column in sqlite table. The problem is the type of data is long in fact but stored as text in the table.How can I do with this strange situation. I've tried of this below but it's not correct

SELECT MAX(ColumnName) FROM TABLE;

But it returned value but not correct!Please someone can help me


回答1:


you could always cast the text to an int:

SELECT MAX(CAST(ColunmName) as int) from TABLE


来源:https://stackoverflow.com/questions/41634060/how-to-get-max-value-of-column-type-integer-stored-as-type-text-in-sqlite-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!