cuong0202 > 27-01-13, 12:42 AM
quanghoasla > 27-01-13, 11:19 AM
cuong0202 > 01-02-13, 10:18 AM
(27-01-13, 11:19 AM)quanghoasla Đã viết: cái này đơn giản thôi mà. dùng desiggn query. sau đó chọn điều kiện cần tìm kiếm trong mục criteria từ khóa ví dụ như: " SU" -> Tương đương với nhà cung cấp sau đó save query đó lại với query lọc nhà cung cấp. Tương tự các query kia cũng làm tương tự.
SELECT Tonct.mahang, Tonct.tenhang, Sum(Tonct.Tondk) AS TonDau, Sum(Tonct.Nhaptk) AS Nhap, Sum(Tonct.Xuattk) AS Xuat, (Sum(Tonct.Tondk)+Sum(Tonct.Nhaptk)-Sum(Tonct.Xuattk)) AS TonCuoi
FROM (Select dk.mahang, dk.tenhang, Tondk, 0 as Nhaptk, 0 as Xuattk From (Select a.mahang, a.tenhang, (Sum(a.Nhap) - Sum(a.Xuat)) AS Tondk From (Select N.mahang, H.tenhang , Sum(N.SoLuong) as Nhap, 0 as Xuat From Qsubnhapkho N, hanghoa H Where N.mahang = H.mahang Group By N.mahang, H.tenhang UNION (Select X.mahang, H.tenhang , 0 as Nhap, sum (X.SoLuong) as Xuat From Qsubxuatkho X, hanghoa H Where X.mahang = H.mahang Group By X.mahang, H.tenhang)) a GROUP BY a.mahang, a.tenhang HAVING (Sum(a.Nhap - a.Xuat))<>0) dk Union Select mahang, tenhang, 0 as Tondk, 0 as Nhaptk, 0 as Xuattk From hanghoa Union Select N.mahang, H.tenhang , 0 as Tondk, Sum(N.SoLuong) as Nhaptk, 0 as Xuattk From Qsubnhapkho N, hanghoa H Where N.mahang = H.mahang Group By N.mahang, H.tenhang Union Select X.mahang, H.tenhang, 0 as Tondk , 0 as Nhaptk, sum (X.SoLuong) as Xuattk From Qsubxuatkho X, hanghoa H Where X.mahang = H.mahang Group By X.mahang, H.tenhang ) AS Tonct
GROUP BY Tonct.mahang, Tonct.tenhang
HAVING (((Sum([Tonct].[Tondk])+Sum([Tonct].[Nhaptk])-Sum([Tonct].[Xuattk]))<>0));
Xuân Thanh > 01-02-13, 12:20 PM
dtv197 > 02-02-13, 10:57 AM