同样的sql 语句在不同机器上得出的记录行数不一样,大家有没有碰到!!!
同样的sql 语句在不同机器上得出的记录行数不一样,大家有没有碰到!!!
我写了一个union all的sql 语句,在同一台服务器上,用我自己的机器能得到3万多条记录,但是用服务器自己的查询分析器只能得到一半的记录,结果是union all 后面的记录没有显示,这是为什么?但是我的机器上执行是正确的,请大家帮忙看看问题到底出在哪里了?
select a=1,h1=1,'' as Wbs_fullcode,'' as wbs_name,D.reserve_dtl_str11 as FPH ,M.CheckedDate as DateUse,
D.Mat_Sid,isnull(D.unitprice,0) as unitprice,D.Title,D.spec+D.model as GGXH,D.unitname,isnull(D.ActualNum,0) as ActualNum,0 as OutNum ,'' LLR, '' LLDW,
reserve_dtl_str2 as CLLB,year(M.CheckedDate) as nian, month(M.CheckedDate) as yue ,day(M.CheckedDate) as ri ,
isnull(D.unitprice*D.ActualNum,0) as DHJE,0 as LYJE ,reserve_dtl_str3 as GYS ,'' as LLDBH,'' AS QGDBH
,traffUnitprice as YFDJ
from view_Mat_DeliveryDetail D,view_Mat_Delivery M
where D.Delivery_Sid=M.Delivery_Sid and M.status='完结' and M.CheckedDate >='2005-12-01' and M.CheckedDate <='2006-12-22'
--- 过滤掉手工批准的
and D.delivery_sid in (select rec_id from pln_act where rec_type='delr' )
--and mat_sid=18884
union
select a=2, h1=1,Wbs_fullcode,D1.wbs_name,'' as FPH,M1.DrawDate as DateUse,D1.Mat_Sid,
isnull(D1.unitprice,0) as unitprice ,D1.Title,D1.spec+D1.model as GGXH,D1.unitname,0 as ActualNum,isnull(D1.ActualGetNum,0) as OutNum ,
M1.drawhuman_name as LLR ,M1.DrawDept_name AS LLDW,
reserve_dtl_str2 as CLLB,year(M1.DrawDate) as nian, month(M1.DrawDate) as yue ,day(M1.DrawDate) as ri ,
0,isnull(D1.unitprice*D1.ActualGetNum,0) as LYJE,'' ,M1.fetchcode, ask.ask_code
,0 as YFDJ
from view_Mat_Fetch M1 ,view_Mat_FetchDetail D1 left join mat_purchaseask ask on D1.sourceid=ask.ask_sid
where D1.Fetch_Sid=M1.Fetch_Sid and M1.status='批准' and D1.HaveFinished='Y' and D1.CheckedDate >='2005-12-01'
and D1.CheckedDate <='2006-12-22'
--- 过滤掉手工批准的
and D1.fetch_sid in (select rec_id from pln_act where rec_type='fetc' )
----保证领料和到货是对应的材料
and D1.mat_sid in (select D2.mat_sid from Mat_DeliveryDetail D2,Mat_Delivery M2
where D2.Delivery_Sid=M2.Delivery_Sid and M2.status='完结' )
--and mat_sid=18884
order by Mat_Sid ,a