SELECT * FROM J;
SELECT * FROM J WHERE CIUDAD = "Londres";
SELECT S# FROM SPJ WHERE J# = "J1" ORDER BY S#;
SELECT * FROM SPJ WHERE CANT >= 300 AND CANT <= 750;

SELECT S#,P#,J# FROM S,P,J WHERE S.CIUDAD=P.CIUDAD AND P.CIUDAD=J.CIUDAD;

SELECT S#,P#,J# FROM S,P,J WHERE S.CIUDAD<>P.CIUDAD AND P.CIUDAD<>J.CIUDAD AND J.CIUDAD<>S.CIUDAD;
SELECT SPJ.P# FROM SPJ JOIN S ON SPJ.S#=S.S# WHERE S.CIUDAD="Londres";
SELECT SPJ.P# FROM SPJ JOIN S ON SPJ.S#=S.S# JOIN J ON SPJ.J#=J.J# WHERE S.CIUDAD="Londres" AND J.CIUDAD="Londres";
SELECT DISTINCT S.CIUDAD, J.CIUDAD FROM SPJ JOIN S ON SPJ.S#=S.S# JOIN J ON SPJ.J#=J.J#;
SELECT SPJ.P# FROM SPJ JOIN S ON SPJ.S#=S.S# JOIN J ON SPJ.J#=J.J# WHERE S.CIUDAD=J.CIUDAD;


SELECT COUNT(pCod) FROM spj WHERE sCod="S1";
SELECT SUM(cant) FROM spj WHERE sCod="S1";
SELECT pCod, jCod, SUM(cant) FROM spj GROUP BY pCod, jCod;
SELECT pCod FROM spj GROUP BY pCod, jCod HAVING AVG(cant) >= 320;
SELECT * FROM spj WHERE cant IS NOT NULL;
SELECT jCod FROM j WHERE ciudad LIKE '_o%';
SELECT jNombre FROM spj JOIN j ON spj.jCod=j.jCod WHERE sCod="S1"; -- (!) No necesite subconsultas
SELECT DISTINCT color FROM spj JOIN p ON spj.pCod=p.pCod WHERE spj.sCod="S1"; -- (!) No necesite subconsultas
SELECT pCod FROM spj WHERE jCod IN (SELECT jCod FROM j WHERE ciudad="Londres")
SELECT DISTINCT jCod FROM spj WHERE pCod IN (SELECT pCod FROM spj WHERE sCod="S1");
SELECT sCod FROM spj WHERE pCod IN (SELECT pCod FROM spj WHERE sCod IN (SELECT sCod FROM spj JOIN p ON spj.pCod=p.pCod WHERE p.color="Rojo")); -- Completamente no checkeado
SELECT sCod FROM s WHERE situacion < (SELECT max(situacion) FROM s WHERE sCod="S1");
SELECT jCod FROM j WHERE ciudad=(SELECT min(ciudad) FROM j);
SELECT pCod FROM spj WHERE EXISTS(SELECT * FROM spj,j WHERE j.ciudad="Londres" AND j.jCod=spj.jCod);
SELECT jCod FROM spj WHERE EXISTS(SELECT * FROM spj,s)


SELECT ciudad FROM s UNION SELECT ciudad FROM j UNION SELECT ciudad FROM p ORDER BY ciudad;
UPDATE p SET color="Gris" WHERE color="Rojo";
DELETE FROM j WHERE NOT EXISTS(SELECT * FROM spj WHERE spj.jCod=j.jCod);
INSERT INTO s(sCod, sNombre, ciudad) VALUES ("S10", "Salazar", "Nueva York"); -- Falla porque situacion es NOT NUL
