有一个数据表如下:
求一个select语句,结果如下(从CouponDenominatoin字段中找到两个数字分别放到两个新增字段):
求一个select语句,结果如下(从CouponDenominatoin字段中找到两个数字分别放到两个新增字段):
解决方案 »
- MAX和SUM同时使用问题
- sql语句
- 怎么过滤SQL关键词汇?
- 整理了一下我的问题。再问一次。谢大家。就是在用sql语句如何给一个数据库分配权限的问题。大家可以进来详看。
- 可能是引号使用错误的一个小问题,有答案马上结帖!
- 存储过程中参数用CONVERT(VARCHAR(10),GETDATE(),111)出错?!
- 存储过程里面表名是变量的问题
- sql2000分区视图查询中一个诡异的问题,当where中是变量时,始终要扫描所有子表
- 用vc++对数据库进行操作中,select * from table;这个table能不能为字符串类型
- 求大神帮忙
- 关于获取存储过程中select语句的显示内容
- sql sserver 表连接
create table test(id int, name varchar(30), f1 int, f2 int)
go
insert into test(id, name) values(1,'满100元减30元')
insert into test(id, name) values(1,'满59元减19元')
insert into test(id, name) values(1,'满10元减3元')
go
update test
set f1= substring(name,2,charindex('元减',name) -2),
f2=replace(substring(name,charindex('元减',name)+2,len(name)),'元','')
go
select * from test
go
drop table test
goid name f1 f2
----------- ------------------------------ ----------- -----------
1 满100元减30元 100 30
1 满59元减19元 59 19
1 满10元减3元 10 3(3 行受影响)
e.g.
SELECT
*
,fieid1=SUBSTRING(CouponDenomination,2,CHARINDEX('元',CouponDenomination)-2)
,fieid2=SUBSTRING(CouponDenomination,CHARINDEX('减',CouponDenomination)+1,LEN(CouponDenomination)-(CHARINDEX('减',CouponDenomination)+1))
FROM table1
FROM YourTable;