有一临时表
declare @t table([id] int,[name] varchar(100))
insert into @t 32
select 1, '#注意 #正常 #异常'
union all select 2, '#正常 #注意'
union all select 3, '#异常 #正常 #正常 #正常'
select * from @t
我要得到查询结果是name字段下面#后面级别最高的信息
id name
1 异常
2 注意
3 异常
declare @t table([id] int,[name] varchar(100))
insert into @t 32
select 1, '#注意 #正常 #异常'
union all select 2, '#正常 #注意'
union all select 3, '#异常 #正常 #正常 #正常'
select * from @t
我要得到查询结果是name字段下面#后面级别最高的信息
id name
1 异常
2 注意
3 异常
解决方案 »
- 我想接触数据库,是新手,那一本书入门好?
- 关于数据库创建时的问题
- 要死了,注册不了外网的服务器
- SQL SERVER安装报错:以前的个程序已在安装计算机上创建挂起的文件操作,
- 无法进入sql2000企业管理器,报“没有找到临时目录,或磁盘空间不足?”
- 数据库中,如何把C60-68分解?
- MSSQL studio 里面没有agent
- 问题???
- 存储过程中调用如下语句 execute immediate 'create global temporary table test (a char(1))' 提示权限不够,为什么?
- 如何实现在SQL Server6.5中的某存储过程,在同一时刻只能由一个用户使用?
- 如何在CMD下用osql执行一个*.sql来创建一个数据库?急!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!谢谢!
- 求一个过程 关于删除空格的
insert into @t
select 1, '#注意 #正常 #异常'
union all select 2, '#正常 #注意'
union all select 3, '#异常 #正常 #正常 #正常' select
id,
case
when charindex('#异常',name)>0 then '#异常'
when charindex('#注意',name)>0 then '#注意'
when charindex('#正常',name)>0 then '#正常'
end as name
from @t/*id name
----------- -----
1 #异常
2 #注意
3 #异常
*/