首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

sql报错。不知怎么改啊消息 8156,级别 16,状态 1,第 28 行

2012-09-10 
sql报错。不知如何改啊。消息 8156,级别 16,状态 1,第 28 行selecta.scph 生产批次1,a.Pcode 产品型号3,a.Xp

sql报错。不知如何改啊。消息 8156,级别 16,状态 1,第 28 行
select a.scph 生产批次1,a.Pcode 产品型号3,a.Xpcode 芯片3,a.Zjcode 支架3,a.WavelengthGrade 芯片波段1,
a.produceqty,a.存量,a.Seq as 配胶方案序号1,
case a.State
when 1 then '待首件方案'
when 2 then '待配首件'
when 3 then '待首件检验'
when 4 then '待自主方案'
when 5 then '待配自主'
when 6 then '待自主检验'
when 7 then '待配批量'
when 8 then '批量结束'
when 9 then '待首件方案'
end 方案状态
from
(select a.id,a.scph,b.Pcode,b.Xpcode,b.Zjcode,a.WavelengthGrade,a.Seq,a.State,c.produceqty,c.存量
  from dbo.Jit_Mucus_RateScheme a 
  inner join jit_rwd b on a.scph=b.scph  
  inner join 
  (select c.scph ,d.scph,c.produceQty,c.produceQty-d.produceQty as 存量
  from( 
  (select scph,produceqty from dbo.View_Jit_rwdProduceProcess
  where StepName='焊芯片/芯片+zener') c
  inner join 
  (select scph,produceqty from dbo.View_Jit_rwdProduceProcess
  where StepName='注胶') d
  on c.scph =d.scph
  )  
  ) c on c.scph=a.Scph
  ) a  
   


[解决办法]

SQL code
SELECT a.scph 生产批次1,       a.Pcode 产品型号3,       a.Xpcode 芯片3,       a.Zjcode 支架3,       a.WavelengthGrade 芯片波段1,       a.produceqty,       a.存量,       a.Seq AS 配胶方案序号1,       CASE a.State            WHEN 1 THEN '待首件方案'            WHEN 2 THEN '待配首件'            WHEN 3 THEN '待首件检验'            WHEN 4 THEN '待自主方案'            WHEN 5 THEN '待配自主'            WHEN 6 THEN '待自主检验'            WHEN 7 THEN '待配批量'            WHEN 8 THEN '批量结束'            WHEN 9 THEN '待首件方案'       END 方案状态FROM   (           SELECT a.id,                  a.scph,                  b.Pcode,                  b.Xpcode,                  b.Zjcode,                  a.WavelengthGrade,                  a.Seq,                  a.State,                  c.produceqty,                  c.存量           FROM   dbo.Jit_Mucus_RateScheme a                  INNER JOIN jit_rwd b                       ON  a.scph = b.scph                  INNER JOIN (                           SELECT c.scph,                                  d.scph,------是不是这里有问题,字段名相同了,加了别名试试                                  c.produceQty,                                  c.produceQty -d.produceQty AS 存量                           FROM   (                                      (                                          SELECT scph,                                                 produceqty                                          FROM   dbo.View_Jit_rwdProduceProcess                                          WHERE  StepName = '焊芯片/芯片+zener'                                      ) c                                      INNER JOIN                                       (                                          SELECT scph,                                                 produceqty                                          FROM   dbo.View_Jit_rwdProduceProcess                                          WHERE  StepName = '注胶'                                      ) d                                      ON c.scph = d.scph                                  )                       ) c                       ON  c.scph = a.Scph       ) a 

热点排行