DELETE FROM R1_;
DELETE FROM C1;
DELETE FROM R1;
INSERT INTO R1_(ID,PRODUCTID1)
SELECT A.SIPARISHEADER_ID,A.PRODUCTID FROM TBLSIPARIS A
GROUP BY A.PRODUCTID,A.SIPARISHEADER_ID
ORDER BY PRODUCTID;
INSERT INTO C1(PRODUCTID1,SUPPORT )
SELECT A.PRODUCTID1,COUNT(*) FROM R1_ A
GROUP BY A.PRODUCTID1
HAVING COUNT(*)>2;
INSERT INTO R1(ID,PRODUCTID1)
SELECT A.ID,A.PRODUCTID1 FROM R1_ A, C1 B
WHERE A.PRODUCTID1 = B.PRODUCTID1;
SELECT A.PRODUCTID1,B.PRODUCTNAME PRODUCTNAME1,A.SUPPORT FROM C1 A
JOIN TBLPRODUCTS B ON (A.PRODUCTID1 = B.PRODUCTID);
答案 0 :(得分:0)
我建议: