这个sql怎么写?

SuperGam 2003-12-22 10:38:46
表table1:
结构如下
name,clientid,fy00,fy01,fy02,...............fy20;
其中clientid为string
fy00...fy20为money。
如果clientid的长度超过10则取fy00..fy20的负值。
怎么写。
谢谢各位了。
...全文
41 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
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
zjcxc 元老 2003-12-22
  • 打赏
  • 举报
回复
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

34,838

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧