2,497
社区成员
发帖
与我相关
我的任务
分享
1.MSSQL语句比较(access改成iif),下面结果:0表示相等,1表示不相等; 至于结果要做什么用,自己看着办吧
select 序号,
case when A=0 then 0 else 1 end as 一月,
case when B=0 then 0 else 1 end as 二月,
case when C=0 then 0 else 1 end as 三月,
case when D=0 then 0 else 1 end as 四月,
case when E=0 then 0 else 1 end as 五月,
case when F=0 then 0 else 1 end as 六月
from (
select 序号,
SUM(case when 标识='A' then 一月 else -一月 end) as A,
SUM(case when 标识='A' then 二月 else -二月 end) as B,
SUM(case when 标识='A' then 三月 else -三月 end) as C,
SUM(case when 标识='A' then 四月 else -四月 end) as D,
SUM(case when 标识='A' then 五月 else -五月 end) as E,
SUM(case when 标识='A' then 六月 else -六月 end) as F
From 表 Group By 序号) as X
/*
序号 一月 二月 三月 四月 五月 六月
----- ----- ----- ----- ----- ----- -----
1 0 1 1 0 0 0
2 1 0 0 0 0 0
(2 行受影响)
*/
2.在程序中比较,就是循环整个表,取出每笔记录中的每个值,上下2条记录比较;自己去实现吧