delete

--DELETE

--2. 41 Xoa khoi bang Nhanvien nhung nhan vien da lam viec trong cong ty qua 40 nam.

/*Delete Nhanvien

Where year(getdate())-year(ngaylamviec)>40*/

--2. 42 Xoa nhung don dat hang truoc nam 2000 ra khoi co so du lieu.

/*Delete Dondathang

Where year(ngaydathang)<2000*/

--2. 43 Xoa khoi bang Loaihang nhung loai hang hien khong co mat hang.

/*Delete Loaihang

From loaihang left join mathang on loaihang.maloaihang=mathang.maloaihang

Where mathang.maloaihang is null*/

--2. 44 Xoa khoi bang Khachhang nhung khach hang hien khong co bat ky don dat hang nao cho cong ty.

/*Delete Khachhang

From Khachhang left join Dondathang on Khachhang.makhachhang=Dondathang.makhachhang

Where Dondathang.makhachhang is null*/

--2. 45 Xoa khoi bang Mathang nhung mat hang co so luong bang 0 va khong duoc dat mua trong bat ky don dat hang nao?

/*Delete Mathang

From mathang left join chitietdathang on mathang.mahang=chitietdathang.mahang

Where mathang.soluong=0 and chitietdathang.mahang is null*/

Bạn đang đọc truyện trên: AzTruyen.Top