有一字段是人名(name):张三、李四、王二、王五、吴三....例如想查询以w开头的人名,结果是:王二、王五、吴三因为用的是虚拟空间,不支持函数,请问大家:可以用一个sql语句实现吗?谢谢先:)
解决方案 »
- 取字符窜问题
- 懂数据库和C#的朋友们,伴我看看吧,关于C#监视一个数据库中的某个表
- sql语句问题
- 求SQL语句
- 如何在存储过程李接受传入的表名和列名?怎样把查询结果赋给一个变量?
- 哈哈,看谁的脑子快!
- 接《一个可能大家都遇到过的问题》zjcxc(邹建) 请进 大家也进来看看~~
- 一个简单的数据库问题
- 求工资管理源代码(vfp)
- 一个关于数据库备份恢复的问题,急急急急!!!!
- SOL Server2000和SQL Server2005客户端能放在一台机器上面吗?
- 定义一个局部变量@SQL varchar(90),set @SQL = 'declare @s nvarchar(100)' + char(13),后面的+ char(13)有什么用啊,请高手帮忙阿,
declare @t table([name] varchar(10))
insert into @t select '张三'
union all select '李四'
union all select '王二'
union all select '王五'
union all select '吴三'select * from @t order by [name] collate Chinese_PRC_CI_AS
insert into @t select '张三'
insert into @t select '李四'
insert into @t select '王二'
insert into @t select '王五'
insert into @t select '吴三'
select
a.name
from
@t a,
(select '吖' chr,'A' letter union all select '八','B' union all
select '嚓','C' union all select '咑','D' union all
select '妸','E' union all select '发','F' union all
select '旮','G' union all select '铪','H' union all
select '丌','J' union all select '咔','K' union all
select '垃','L' union all select '嘸','M' union all
select '拏','N' union all select '噢','O' union all
select '妑','P' union all select '七','Q' union all
select '呥','R' union all select '仨','S' union all
select '他','T' union all select '屲','W' union all
select '夕','X' union all select '丫','Y' union all
select '帀','Z') b
where
b.chr<=left(a.name,1)
group by
a.name
having max(letter)='W'/*
name
----------
王二
王五
吴三
*/