feeling > 03-08-19, 04:56 PM
Noname > 03-08-19, 05:27 PM
SELECT QR_DAUKY.IDOITUONG, QR_DAUKY.TENDOITUONG, QR_DAUKY_BC.TonDauBC, Sum(Nz([THU])) AS Nhap, Sum(Nz([CHI])) AS Xuat, Nz([TonDauBC])+Nz([THU])-Nz([CHI]) AS TCBC
FROM ((QR_DAUKY LEFT JOIN QR_TONGTHU ON QR_DAUKY.IDOITUONG = QR_TONGTHU.IDOITUONG) LEFT JOIN QR_DAUKY_BC ON QR_DAUKY.IDOITUONG = QR_DAUKY_BC.IDOITUONG) LEFT JOIN QR_TONGCHI ON QR_DAUKY.IDOITUONG = QR_TONGCHI.IDOITUONG
GROUP BY QR_DAUKY.IDOITUONG, QR_DAUKY.TENDOITUONG, QR_DAUKY_BC.TonDauBC, Nz([TonDauBC])+Nz([THU])-Nz([CHI])
HAVING (((QR_DAUKY.IDOITUONG) Like "*" & [Forms]![F_TAMUNG]![txtDT] & "*") AND ((QR_DAUKY_BC.TonDauBC)<>0)) OR (((QR_DAUKY.IDOITUONG) Like "*" & [Forms]![F_TAMUNG]![txtDT] & "*") AND ((Sum(Nz([THU])))<>0)) OR (((QR_DAUKY.IDOITUONG) Like "*" & [Forms]![F_TAMUNG]![txtDT] & "*") AND ((Sum(Nz([CHI])))<>0));