30 likes | 195 Views
SELECT * FROM CarType WHERE mark = 'Peugeot' SELECT cust_id,COUNT(*) AS count FROM Rent GROUP BY cust_id SELECT COUNT(*) AS 'over 45' FROM Car WHERE rate > 45 SELECT lastname FROM Customer WHERE lastname LIKE 'C%‘ ORDER BY lastname DESC INSERT INTO Customer
E N D
SELECT * FROM CarType WHERE mark = 'Peugeot' SELECT cust_id,COUNT(*) AS count FROM Rent GROUP BY cust_id SELECT COUNT(*) AS 'over 45' FROM Car WHERE rate > 45 SELECT lastname FROM Customer WHERE lastname LIKE 'C%‘ ORDER BY lastname DESC INSERT INTO Customer (lastname,firstname) VALUES ('Wayne','John') UPDATE Customer SET address = '2 Main St.' WHERE lastname = 'Wayne' AND firstname = 'John' UPDATE Customer SET postal_code = '23456’ WHERE lastname = 'Wayne' AND firstname = 'John' SELECT Rent.cust_id, lastname, firstname, reg_no FROM Rent,Customer WHERE Rent.cust_id < 4 AND Rent.cust_id = Customer.cust_id SELECT * FROM Car WHERE rate < (SELECT AVG(rate) FROM Car) Solutions (Repetition)
INSERT INTO Rent (cust_id, reg_no, rent_date) VALUES (4 , 'BSA-224', '11.4.2005') SELECT reg_no, MIN(rent_date) AS Min, MAX(rent_date) AS Max FROM Rent GROUP BY reg_no SELECT Rent.reg_no, mark, model, rent_date FROM Rent, Car, CarType WHERE Rent.reg_no LIKE 'B%‘ AND return_date IS NULL AND Rent.reg_no=Car.reg_no AND Car.model_id=CarType.model_id SELECT * FROM Rent SELECT Car.reg_no, mark , model FROM Car, CarType WHERE Car.model_id = CarType.model_id AND rate BETWEEN 30 AND 50 INSERT INTO car (reg_no, model_id) VALUES ('EEE-666', 2) UPDATE car SET rate = 60 WHERE reg_no = 'EEE-666‘ SELECT COUNT(*) AS 'rents in 2005' FROM Rent WHERE YEAR(rent_date) = 2005 Solutions
SELECT cust_id, COUNT(*) AS count FROM Rent GROUP BY cust_id SELECT lastname FROM Customer WHERE lastname LIKE 'A%s‘ SELECT cust_id FROM Rent GROUP BY cust_id HAVING COUNT(*) > 2 Solutions