btamsgn > 24-02-22, 04:41 PM
ttm20062008 > 25-02-22, 11:29 AM
ongke0711 > 25-02-22, 12:39 PM
SELECT Tb1.MaID, Da.Ngay, Tb1.GT AS A1,0 As A2,0 As A3,0 As A4
FROM Tb1 INNER JOIN Da ON Tb1.GT = Da.C1
UNION
SELECT Tb1.MaID, Da.Ngay,0 As A1, Tb1.GT AS A2,0 As A3,0 As A4
FROM Tb1 INNER JOIN Da ON Tb1.GT = Da.C2
UNION
SELECT Tb1.MaID, Da.Ngay,0 As A1,0 As A2, Tb1.GT AS A3,0 As A4
FROM Tb1 INNER JOIN Da ON Tb1.GT = Da.C3
UNION SELECT Tb1.MaID, Da.Ngay,0 As A1,0 As A2, 0 As A3, Tb1.GT AS A4
FROM Tb1 INNER JOIN Da ON Tb1.GT = Da.C4;
SELECT Tb2.MaH, Da.Ngay, Tb2.GT1 AS A1, 0 AS A2, 0 AS A3, 0 AS A4
FROM Tb2 INNER JOIN Da ON Tb2.GT1 = Da.C1
UNION
SELECT Tb2.MaH, Da.Ngay,0 As A1, Tb2.GT2 AS A2, 0 AS A3, 0 AS A4
FROM Tb2 INNER JOIN Da ON Tb2.GT2 = Da.C2
UNION
SELECT Tb2.MaH, Da.Ngay, 0 AS A1, 0 AS A2, Tb2.GT3 AS A3, 0 AS A4
FROM Tb2 INNER JOIN Da ON Tb2.GT3 = Da.C3
UNION SELECT Tb2.MaH, Da.Ngay, 0 AS A1, 0 AS A2,0 As A3, Tb2.GT4 AS A4
FROM Tb2 INNER JOIN Da ON Tb2.GT4 = Da.C4;
btamsgn > 25-02-22, 10:50 PM