declare @tb table(smonth varchar(100))
insert into @tb
select '10月' union all
select '11月' union all
select '8月' union all
select '8月' select * from @tb order by smonth
/*
而我想要的结果
smonth
------
8月
8月
10月
11月
*/
insert into @tb
select '10月' union all
select '11月' union all
select '8月' union all
select '8月' select * from @tb order by smonth
/*
而我想要的结果
smonth
------
8月
8月
10月
11月
*/
解决方案 »
- 大家有没有遇到过视图坏掉的情况?
- sql递归查找子类型
- SQL SERVER 2005安装问题
- 求高效率查詢語句,各位請幫忙,謝謝!
- 当在INNER JOIN加条件时在ON后面A.ID=B.ID AND A.ID=1和INNER JOIN加条件时在ON后面A.ID=B.ID WHERE A.ID=1有什么区别
- 怎样理解SQL SERVER 2000中BOOL数据类型的UNKNOW布尔值?
- 寻找前5条记录可用select top 5 * from table,那寻找最后5条记录,如何写?
- 急:请教SQL Server 6.5 在Win 2000 Server上的安装
- 数据库存储问题,我想在数据库的表中只存储3个月的数据,实现滚动存储,新的月份的数据加进来,最前面一个月的数据自动删去
- 我在修改一sqlserver数据库时遇到了个问题:
- 求一个插入操作之前的触发器
- sql比较
insert into @tb
select '10月' union all
select '11月' union all
select '8月' union all
select '8月'
select * from @tb order by cast(left(smonth,len(smonth)-1)as int) asc
/*smonth
----------------------------------------------------------------------------------------------------
8月
8月
10月
11月*/
select * from @tb
order by cast(replace(smonth,'月','') as int)smonth
---------------
8月
8月
10月
11月(4 行受影响)
insert into @tb
select '10月' union all
select '11月' union all
select '8月' union all
select '8月' select * from @tb order by cast(replace(smonth ,'月','') as int)/*
smonth
----------------------------------------------------------------------------------------------------
8月
8月
10月
11月(所影响的行数为 4 行)
*/
insert into @tb
select '10月' union all
select '11月' union all
select '8月' union all
select '8月' select *
from @tb
order by right('00'+smonth,3)/**
smonth
----------------------------------------------------------------------------------------------------
8月
8月
10月
11月(所影响的行数为 4 行)
**/
insert into @tb
select '10月' union all
select '11月' union all
select '8月' union all
select '8月' select *
from @tb
order by right('00'+smonth,3)/**
smonth
----------------------------------------------------------------------------------------------------
8月
8月
10月
11月(所影响的行数为 4 行)
**/
declare @tb table(smonth varchar(100))
insert into @tb
select '10月' union all
select '11月' union all
select '8月' union all
select '8月' select * from @tb order by cast(replace(smonth ,'月','') as int)/*
smonth
----------------------------------------------------------------------------------------------------
8月
8月
10月
11月(所影响的行数为 4 行)
*/