我为什么这么笨??
ysf1 2005-01-26 10:15:30 select rtrim(b.khmc) as 客户名称,rtrim(a.djbh) as 入库单号, rtrim(a.hwmc) as 货物名称,
(case when djlx='ZLRK' then '重量' else '平方' end ) as 单据类型,
convert(char(10), sj,120) as 入库时间,
(select sum(case when djlx in ('CK','BS') then (-1)*sl else sl end) as sl from kcjl
where djlx in ('ZLRK','PFRK','BC','CK','BS') and ((djbh=a.djbh and djlx in ('ZLRK','PFRK'))or(hwmc=a.djbh and djlx NOT in('ZLRK','PFRK'))))as 当前数量,
a.dw as 单位,(case when djlx='ZLRK' then 当前数量*gs else gs end ) as 顿位或平方,
a.dj as 单价,((case when djlx='ZLRK' then 当前数量*gs else gs end )*dj) as 每天金额
from kcjl a ,khxx b where djlx in ('ZLRK','PFRK') and a.khbh=b.khbh
其实吧,不要看好像很复杂,其实问题很简单,
从第三行到第五行是一个字段,当前数量,这个字段肯定就很麻烦啦,
关键是我在后面要两次用到这个字段,就是出现这个"当前数量"的地方,
nnd,不让我用,干!!
提示:
服务器: 消息 207,级别 16,状态 3,行 1
列名 '当前数量' 无效。
服务器: 消息 207,级别 16,状态 1,行 1
列名 '当前数量' 无效。
要是每次出现这个当前数量,我都要把那个再写一遍岂不是太麻烦了,
而且我想ms不至于这么蠢,连这个功能都没有吧,所以肯定是我蠢,请大家指教!!