如何在不同情况下按表列排序(Oracle) [英] How can I sort by a table column in varying cases (Oracle)

查看:84
本文介绍了如何在不同情况下按表列排序(Oracle)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何对带有varchar2列且具有不同大小写字符()的字符进行排序?

How can I sort a table with a column of varchar2 with characters in varying cases (UPPER and lower)?

例如,当我按名称"列进行排序时,将得到以下结果:

For example, when I do an order by of the Name column, I get the following results:

ANNIE
BOB
Daniel
annie
bob

我想要的是这样的

ANNIE
annie
BOB
bob
Daniel

推荐答案

使用lower(field),例如

select * from tbl order by lower(name)

如果您需要解决非英语语言的特殊字符,则可能需要有关NLSSORT的其他答案.如果您不这样做,我会尝试和KISS一起使用lower(),因为它很容易记住和使用,并易于被他人阅读(可维护性).

If you need to address special characters for non-english languages then the other answers about NLSSORT may be what you need. If you don't I would try and KISS and use lower() as it is very easy to remember and use and be read by others (maintainability).

这篇关于如何在不同情况下按表列排序(Oracle)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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