发布网友 发布时间:2023-03-07 07:24
共1个回答
热心网友 时间:2023-10-06 04:34
1.SELECT DISTINCT S.SN FROM S WHERE S.SNO IN(SELECT SP.SNO FROM SP,P WHERE SP.PNO = P.PNO AND P.PN='TV')2.SELECT PN FROM P WHERE COLOR = (SELECT COLOR FROM P WHERE PN = 'TV')3.SELECT S.SN,Q.PN FROM S,(SELECT P.PN,SP.PNO,SP.SNO FROM P,SP WHERE P.PNO = SP.PNO AND ( P.PN = 'P1' OR P.PN = 'P2' )) AS Q WHERE S.SNO = Q.SNO4.SELECT T.PN,T.CITY,SUM(T.QTY) FROM (SELECT S.SNO,S.CITY,Q.QTY,Q.PN FROM (SELECT P.PN,SP.QTY,SP.SNO FROM P,SP WHERE P.PNO = SP.PNO) AS Q WHERE S.SNO = Q.SNO) AS T WHERE T.CITY = '上海' GROUP BY T.PNO 试试,凭空写的,如有小错自己修改下