@@prasertcbs อาจารย์ครับ ผมเขียนประมาณนี้ยัง Error ครับ create view cte as(select group_no,group_name,a.item,item_desc,item_desc_secondary,type_adj,sum(total_cost) tt_cost from zTW_2019 a,item_master b,reason_adj c where mm = '9' and tran_code in ('22','23') and gl_ref_no in ('11','13','911','913') and a.item in (select item from item_)
--join table and a.item = b.item and a.gl_ref_no = c.code group by group_no,group_name,a.item,item_desc,item_desc_secondary,type_adj) select ac.group_no,ac.group_name,ac.item,ac.item_desc,ac.item_desc_secondary,ac.tt_cost [Damage],ac.tt_cost [Expire] from cte ac inner join cte ad on ac.item = ad.item and ac.type_adj = '1Damage' and ad.type = '3Expire'
หามานานมากดลยครับอาจารย์ ต้องคอย insert เข้า table อื่นก่อนตลอดเลย
ขอบคุณมากครับ อาจารย์❤
อาจารย์ครับ sql2000 ไม่มี with ต้องเขียนยังไงครับ
ใช้ view ครับ
@@prasertcbs อาจารย์ครับ ผมเขียนประมาณนี้ยัง Error ครับ
create view cte as(select group_no,group_name,a.item,item_desc,item_desc_secondary,type_adj,sum(total_cost) tt_cost
from zTW_2019 a,item_master b,reason_adj c
where mm = '9'
and tran_code in ('22','23')
and gl_ref_no in ('11','13','911','913')
and a.item in (select item from item_)
--join table
and a.item = b.item and a.gl_ref_no = c.code
group by group_no,group_name,a.item,item_desc,item_desc_secondary,type_adj)
select ac.group_no,ac.group_name,ac.item,ac.item_desc,ac.item_desc_secondary,ac.tt_cost [Damage],ac.tt_cost [Expire]
from cte ac inner join cte ad on ac.item = ad.item and ac.type_adj = '1Damage' and ad.type = '3Expire'
ขอชื่อของโปรแกรมหน่อย