delphi中向adoquery中添加字段报错。求改正。
declare@dtstartsmalldatetime,@dtendsmalldatetimeset@dtstart=:pstartset@dtend=:pendsel...
declare @dtstart smalldatetime,@dtend smalldatetime
set @dtstart=:pstart
set @dtend=:pend
select '1.按批次' as flag,a.scph,a.pcode,a.type,a.mattype,a.mdate,a.producetype,a.xpcode,a.zjcode,a.planqty,a.qty,(a.planqty-a.qty) as notqty,isnull(e.qty,0) as badqty
,case when a.qty=0 then 0 else isnull(e.qty,0)*1.0/a.qty*100 end as qper
,case when a.qty=0 then 0 else isnull(e.qty,0)*1.0/a.qty end*1000000 as qppm
,isnull(e.qty01,0) as 多胶,isnull(e.qty02,0) as 少胶,isnull(e.qty03,0) as 报废
,isnull(e.qty04,0) as 溢胶,isnull(e.qty05,0) as 气泡,isnull(e.qty06,0) as 裂胶,isnull(e.qty07,0) as 杂物
,isnull(e.qty08,0) as 黑点,isnull(e.qty09,0) as 固晶不良,isnull(e.qty10,0) as 焊线不良,isnull(e.qty11,0) as 焊线报废
,isnull(e.qty12,0) as 固晶报废,isnull(e.qty13,0) as 地检品,isnull(e.qty14,0) as 支架脚不良
from
(select a.scph,b.pcode,c.type,c.mattype,b.xpcode,b.zjcode,b.producetype,b.planqty,sum(a.qty+a.badqty+a.WasteQty+a.IllQty+a.OtherIllQty) as qty
,case when sum(a.qty+a.badqty+a.WasteQty+a.IllQty+a.OtherIllQty)>=b.planqty then convert(varchar(10),max(importtime),121) else '' end as Mdate
from jit_rbb a inner join jit_rwd b on a.scph=b.scph
inner join material c on b.pcode=c.code
inner join Jit_base_step d on a.stepno=d.stepno
where ((b.state<>4 and b.planstartdate<dateadd(m,datediff(m,0,@dtstart)+1,0))
or (b.state=4 and b.enddate>=dateadd(m,datediff(m,0,@dtstart),0)))
and d.stepname='冲压'
group by a.scph,b.pcode,c.type,c.mattype,b.planqty,b.producetype,b.xpcode,b.zjcode) a
left join
(select a.scph,sum(a.qty) as qty,sum(qty01) as qty01,sum(qty02) as qty02 ,sum(qty03) as qty03
,sum(qty04) as qty04 ,sum(qty05) as qty05 ,sum(qty06) as qty06 ,sum(qty07) as qty07
,sum(qty08) as qty08 ,sum(qty09) as qty09 ,sum(qty10) as qty10 ,sum(qty11) as qty11
,sum(qty12) as qty12 ,sum(qty13) as qty13 ,sum(qty14) as qty14 展开
set @dtstart=:pstart
set @dtend=:pend
select '1.按批次' as flag,a.scph,a.pcode,a.type,a.mattype,a.mdate,a.producetype,a.xpcode,a.zjcode,a.planqty,a.qty,(a.planqty-a.qty) as notqty,isnull(e.qty,0) as badqty
,case when a.qty=0 then 0 else isnull(e.qty,0)*1.0/a.qty*100 end as qper
,case when a.qty=0 then 0 else isnull(e.qty,0)*1.0/a.qty end*1000000 as qppm
,isnull(e.qty01,0) as 多胶,isnull(e.qty02,0) as 少胶,isnull(e.qty03,0) as 报废
,isnull(e.qty04,0) as 溢胶,isnull(e.qty05,0) as 气泡,isnull(e.qty06,0) as 裂胶,isnull(e.qty07,0) as 杂物
,isnull(e.qty08,0) as 黑点,isnull(e.qty09,0) as 固晶不良,isnull(e.qty10,0) as 焊线不良,isnull(e.qty11,0) as 焊线报废
,isnull(e.qty12,0) as 固晶报废,isnull(e.qty13,0) as 地检品,isnull(e.qty14,0) as 支架脚不良
from
(select a.scph,b.pcode,c.type,c.mattype,b.xpcode,b.zjcode,b.producetype,b.planqty,sum(a.qty+a.badqty+a.WasteQty+a.IllQty+a.OtherIllQty) as qty
,case when sum(a.qty+a.badqty+a.WasteQty+a.IllQty+a.OtherIllQty)>=b.planqty then convert(varchar(10),max(importtime),121) else '' end as Mdate
from jit_rbb a inner join jit_rwd b on a.scph=b.scph
inner join material c on b.pcode=c.code
inner join Jit_base_step d on a.stepno=d.stepno
where ((b.state<>4 and b.planstartdate<dateadd(m,datediff(m,0,@dtstart)+1,0))
or (b.state=4 and b.enddate>=dateadd(m,datediff(m,0,@dtstart),0)))
and d.stepname='冲压'
group by a.scph,b.pcode,c.type,c.mattype,b.planqty,b.producetype,b.xpcode,b.zjcode) a
left join
(select a.scph,sum(a.qty) as qty,sum(qty01) as qty01,sum(qty02) as qty02 ,sum(qty03) as qty03
,sum(qty04) as qty04 ,sum(qty05) as qty05 ,sum(qty06) as qty06 ,sum(qty07) as qty07
,sum(qty08) as qty08 ,sum(qty09) as qty09 ,sum(qty10) as qty10 ,sum(qty11) as qty11
,sum(qty12) as qty12 ,sum(qty13) as qty13 ,sum(qty14) as qty14 展开
展开全部
主要是下面这两句,@dtstart,@dtend赋值的时候是不是用了text类型
declare @dtstart smalldatetime,@dtend smalldatetime
set @dtstart=:pstart
set @dtend=:pend
where ((b.state<>4 and b.planstartdate<dateadd(m,datediff(m,0,@dtstart)+1,0))
or (b.state=4 and b.enddate>=dateadd(m,datediff(m,0,@dtstart),0)))
declare @dtstart smalldatetime,@dtend smalldatetime
set @dtstart=:pstart
set @dtend=:pend
where ((b.state<>4 and b.planstartdate<dateadd(m,datediff(m,0,@dtstart)+1,0))
or (b.state=4 and b.enddate>=dateadd(m,datediff(m,0,@dtstart),0)))
追问
麻烦你加我一下345565208 备注。谢了。
text找不到啊
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询