导航
  • 主页
  • 基础类
  • 应用实例
  • 新技术前沿

这个sql怎么写?

SuperGam 2003-12-22 10:38:46
表table1:
结构如下
name,clientid,fy00,fy01,fy02,...............fy20;
其中clientid为string
fy00...fy20为money。
如果clientid的长度超过10则取fy00..fy20的负值。
怎么写。
谢谢各位了。
...全文
4 点赞 收藏 5
写回复
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
SuperGam 2004-02-24
哪个速度快呢?
回复
gmlxf 2003-12-22
把马可的稍改一下:
select name,
clientid,
fy00*x as fy00,
fy01*x as fy01,
...
fy20*x as fy20
from ( select *,
(case when len(clientid)>10 then -1 else 1 end) as X
from table1
) a
回复
select name,clientid
,fy00=case when len(clientid)>10 then -fy00 else fy00 end
,fy01=case when len(clientid)>10 then -fy01 else fy01 end
...
,fy19=case when len(clientid)>10 then -fy19 else fy19 end
,fy20=case when len(clientid)>10 then -fy20 else fy20 end
from table1
回复
txlicenhe 2003-12-22
把中海的稍改一下:
select name,
clientid,
fy00*x as fy00,
fy01*x as fy01,
...
fy20*x as fy20
from ( select *,
(case when len(clientid)>10 then -1 else 1 end) as X
from table1
) b
on a.name=b.name
回复
victorycyz 2003-12-22
select name,
clientid,
fy00*x as fy00,
fy01*x as fy01,
...
fy20*x as fy20
from table1 a join
( select [name],
(case when len(clientid)>10 then -1 else 1 end) as X
from table1
) b
on a.name=b.name
回复
发动态
发帖子
MS-SQL Server
创建于2007-09-28

3.2w+

社区成员

MS-SQL Server相关内容讨论专区
申请成为版主
社区公告
暂无公告