XÓA BỎ DÒNG KHÔNG PHÁT SINH

YÊU CẦU

  • Nếu danh mục không phát sinh thì xóa bỏ

HƯỚNG DẪN

  • Code mặc định 1 danh mục muốn xử lý

-- chạy select  kiểm tra
-- okie thì comment select, mở delete
select  t1.ma,t1.ten,t1.VuViec as id_danhmuc, t2.vuviec
-- delete T1
from
(select * from vuviec where vuviec<>0 and cap=0)T1 left join
(
	select vuviec 
	from dulieuketoan 
	where vuviec<>0
	group by vuviec 
)T2 on t1.VuViec = t2.VuViec
where t2.VuViec is null

Last updated