[英]Arrange data in ascending order in SQL SERVER 2008
I have a table in which one of the column stores name. 我有一个表,其中一列存储名称。 The names are stored as John,jimmy,Steve,smith,Shaun. 名称存储为John,jimmy,Steve,smith,Shaun。
I would like to display it as 我想显示为
jimmy
John
Shaun
smith
Steve
The name are displayed in alphabetical order. 名称以字母顺序显示。
Which query should I use in SQL SERVER 2008. I have tried using collate nocase
which gave me an error. 我应该在SQL SERVER 2008中使用哪个查询。我尝试使用collate nocase
,这给了我一个错误。 My database collation
is Latin1_General_CI_AS
我的数据库collation
Latin1_General_CI_AS
是Latin1_General_CI_AS
Simple 简单
SELECT * FROM table ORDER BY [name] ASC
Doesn't work for you ? 不适合您吗?
Use ORDER BY CLAUSE , It will resolve your problem 使用ORDER BY CLAUSE ,它将解决您的问题
select name from tablename order by name COLLATE NOCASE.
OR 要么
select name from tablename order by Lower(name)
With collate
you specify how the column values are treated in operations, if eg equality check is case sensitive or case insensitive. 使用collate
您可以指定在操作中如何处理列值(例如,相等性检查区分大小写还是不区分大小写)。 This has nothing to do with ordering your values using a select
statement. 这与使用select
语句对值进行排序无关。
The ordering is simply forced by an order by
like already said. 就像已经说过order by
那样,简单地通过order by
强制排序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.