22,206
社区成员
发帖
与我相关
我的任务
分享
create table #tb1(dt varchar(10))
insert #tb1 select '21:00'
insert #tb1 select '22:00'
insert #tb1 select '5:00'
insert #tb1 select '6:30'
select * from #tb1 order by cast( replace(dt,':','.') as float) asc
sql="select * from 表1 where 字段1='"&daynow&"' order by cast(字段2 as datetime) asc"
create table #tb1(dt varchar(10))
insert #tb1 select '21:00'
insert #tb1 select '22:00'
insert #tb1 select '5:00'
insert #tb1 select '6:30'
select * from #tb1 order by cast(dt as datetime)
/*dt
----------
5:00
6:30
21:00
22:00
(4 行受影响)
*/
create table tab(c1 varchar(10))
go
insert tab
select '21:00'
union select '22:00'
union select '5:00'
union select '6:30'
select *
from tab
order by right('00'+c1,5)
drop table tab
/*
c1
----------
5:00
6:30
21:00
22:00
(4 個資料列受到影響)
*/
create table tab(c1 varchar(10))
go
insert tab
select '21:00'
union select '22:00'
union select '5:00'
union select '6:30'
select * from tab order by cast(substring(c1,1,charindex(':',c1)-1) as int) asc
drop table tab
sql="select * from 表1 where 字段1='"&daynow&"' order by cast(substring(字段2,1,charindex(':',字段2)-1) as int) asc"
create table #tb1(dt varchar(10))
insert #tb1 select '21:00'
insert #tb1 select '22:00'
insert #tb1 select '5:00'
insert #tb1 select '6:30'
select * from #tb1 order by cast('1900-1-1 '+dt as datetime) desc
dt
----------
22:00
21:00
6:30
5:00
(4 行受影响)