+ -
当前位置:首页 → 问答吧 → 关于查询语句的排序

关于查询语句的排序

时间:2011-11-22

来源:互联网

select 姓名,case when charindex('您好',备注)>0 then '*' else '' end as 备注 order by 备注
我想让所有带*排在一起,order by 语句怎么写?

作者: hnymx2005   发布时间: 2011-11-22

SQL code
select 姓名
FROM 
table1
ORDER BY 
case when charindex('您好',备注)>0 then '*' else '' end,备注

作者: roy_88   发布时间: 2011-11-22

SQL code
select 姓名,case when charindex('您好',备注)>0 then '*' else '' end as 备注 order by 2

作者: Haiwer   发布时间: 2011-11-22

SQL code
select 姓名
FROM 
table1
ORDER BY 
case when charindex('您好',备注)>0 then 1 else 2 end,备注

作者: roy_88   发布时间: 2011-11-22

select 姓名,case when charindex('您好',备注)>0 then '*' else '' end as 备注 order by 2

作者: ssp2009   发布时间: 2011-11-22

引用 2 楼 haiwer 的回复:

SQL code
select 姓名,case when charindex('您好',备注)>0 then '*' else '' end as 备注 order by 2


order by 2 //按筛选的第二列排序

参考:http://topic.csdn.net/t/20061212/17/5225505.html
学习!!

作者: xiaolinyouni   发布时间: 2011-11-22

SQL code

select 姓名,case when charindex('您好',备注)>0 then '*' else '' end as 备注 order by 
case when charindex('您好',备注)>0 then 0 else 1 end

作者: pengxuan   发布时间: 2011-11-22

vfp9.0:
sele 姓名, 备注 from tt where 备注 like %"您好"% into table mytt
update mytt set 备注='*'

由于不清楚charindex()?可能不符合楼主的意思。

作者: jxjdzwang5555   发布时间: 2011-11-22

引用 7 楼 jxjdzwang5555 的回复:

vfp9.0:
sele 姓名, 备注 from tt where 备注 like %"您好"% into table mytt
update mytt set 备注='*'

由于不清楚charindex()?可能不符合楼主的意思。


select 姓名, 备注 from tt where 备注 like %'您好'% into table mytt
update mytt set 备注='*'

作者: xiaolinyouni   发布时间: 2011-11-22