HOME > ASP > ASP Forum > ช่วยดู code ให้หน่อยครับงงครับ....เมื่อ select ข้อมูล 2 select หลัง เมื่อแยก select แล้วไม่มีข้อมูลเลยข้อมูลทั้งหมดมาจาก select อันแรกครับ.
select i.receiptnum,i.docnum,i.doctotal,i.cardname,convert(char,i.docduedate,101) as docduedate,v.itemcode,v.dscription,v.quantity,v.price,v.vatgroup,v.slpcode,(((v.price*v.quantity)*100)/107)as Amt,v.docdate,v.docentry,c.docnum,convert(char,c.docdate,101) as date,s.slpname,v.objtype,i.discsum,i.DpmAmnt,v.wtliable,c.jrnlmemo,i.DiscPrcnt from oinv i inner join inv1 v on i.docentry = v.docentry inner join orct c on i.receiptnum=c.docnum inner join oslp s on i.slpcode=s.slpcode where c.docduedate BETWEEN '09/01/2010' and '9/30/2010' and s.slpcode='7' and c.jrnlmemo<>'Cancelled' and i.docstatus='C'
union select o.receiptnum,o.docnum,o.doctotal,o.cardname,convert(char,o.docduedate,101) as docduedate,n.itemcode,n.dscription,n.quantity,n.price,n.vatgroup,n.slpcode,(((n.price*n.quantity)*100)/107)as Amt,n.docdate,n.docentry,c.docnum,convert(char,c.docdate,101) as date,s.slpname,n.objtype,o.discsum,o.DpmAmnt,n.wtliable,c.jrnlmemo,o.DiscPrcnt from orin o inner join rin1 n on o.docentry = n.docentry inner join orct c on o.receiptnum=c.docnum inner join oslp s on o.slpcode=s.slpcode where c.docduedate BETWEEN '09/01/2010' and '9/30/2010' and s.slpcode='7' and c.jrnlmemo<>'Cancelled' and o.docstatus='C'
union select p.receiptnum,p.docnum,p.doctotal,p.cardname,convert(char,p.docduedate,101) as docduedate,d.itemcode,d.dscription,d.quantity,d.price,d.vatgroup,d.slpcode,(((d.price*d.quantity)*100)/107)as Amt,d.docdate,d.docentry,c.docnum,convert(char,c.docdate,101) as date,s.slpname,d.objtype,p.discsum,p.DpmAmnt,d.wtliable,c.jrnlmemo,p.DiscPrcnt from odpi p inner join dpi1 d on p.docentry = d.docentry inner join orct c on p.docnum=c.docnum inner join oslp s on p.slpcode=s.slpcode where c.docduedate BETWEEN '09/01/2010' and '9/30/2010' and s.slpcode='7' and c.jrnlmemo<>'Cancelled' and p.docstatus='C'
เมื่อ unoin กันแล้ว มันจะได้ 21 record
แต่เมื่อแยก select มันจะได้ 22 record ครับผมอยากทราบว่าเพราะอะไรงงครับ