SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE customers ( name char(25), driversLicense char(50) ); INSERT INTO customers VALUES ('Sally Phillips', 'NY774055434'); INSERT INTO customers VALUES ('Steven Smith', 'NY160423658'); INSERT INTO customers VALUES ('Gary Moore', 'MA942299072'); INSERT INTO customers VALUES ('Bill Barnes', 'CT896900826'); INSERT INTO customers VALUES ('Mary Anderson', 'NY132497102'); SELECT * from customers; CREATE TABLE vehicles ( Year char(25), Make char(25), Model char(25), Trim char(25), Mileage char(25), Color char(25), Price char(25), Vin char(25), Buyer char(25) ); INSERT INTO vehicles VALUES ('2010', 'FORD', 'TAURUS', 'SEL', '2572', 'White', '25600', '1FAHP2EW1AG163911', ' '); INSERT INTO vehicles VALUES ('2008', 'JEEP', 'GR CHEROKEE', '4x4 LIMITED', '33860', 'White', '23700', '1J8HR582X8C117809', '1'); INSERT INTO vehicles VALUES ('2007', 'JEEP', 'GR CHEROKEE', '4x4 LIMITED', '20155', 'White', '21900', '1J8HR58257C662217', ' '); INSERT INTO vehicles VALUES ('2009', 'FORD', 'ESCAPE', '4x2 LIMITED', '11354', 'Green', '21100', '1FMCU04G69KB01856', ' '); INSERT INTO vehicles VALUES ('2008', 'DODGE', 'GHARGER', 'R/T', '34602', 'Yellow', '20250', '2B3LA53H38H185713', ' '); INSERT INTO vehicles VALUES ('2008', 'LINCOLN', 'MKZ', ' ', '15772', 'Red', '20250', '3LNHM26T08R656808', ' '); INSERT INTO vehicles VALUES ('2009', 'CHEVROLET', 'TRAILBLAZER', '4x4 LT', '35635', 'White', '19000', '1GNDT33SX92102535', ' '); INSERT INTO vehicles VALUES ('2008', 'DODGE', 'RAM 1550', '4x4 QD', '68314', 'Green', '18600', '1D7HU18268J115846', ' '); INSERT INTO vehicles VALUES ('2009', 'FORD', 'FUSION', 'SEL', '34595', 'Grey', '13950', '3FAHP08119R159916', '1'); INSERT INTO vehicles VALUES ('2007', 'MERCURY', 'GRAND MARQUIS', 'GS', '19128', 'Gold', '11750', '2MEFM74VX7X617445', ' '); INSERT INTO vehicles VALUES ('2006', 'CHEVROLET', 'COBALT', 'LT', '48021', 'White', '7375', '1G1AL55F167732362', ' '); INSERT INTO vehicles VALUES ('2007', 'BUICK', 'LUCERNE', 'CX', '36225', 'Tan', '13050', '1G4HP57247U112723', '4'); INSERT INTO vehicles VALUES ('2009', 'HYUNDAI', 'SONATA', '4C GLS', '30162', 'Tan', '11600', '5NPET46C89H532795', ' '); INSERT INTO vehicles VALUES ('2007', 'JEEP', 'COMPASS', '4x4', '33296', 'Silver', '14050', '1J8FF47WX7D357711', ' '); INSERT INTO vehicles VALUES ('2008', 'FORD', 'FOCUS', 'SES', '35668', 'Silver', '11350', '1FAHP33N68W238747', ' '); INSERT INTO vehicles VALUES ('2001', 'FORD', 'EXPLORER', '4x4 SPORT', '61777', 'Blue', '5325', '1FMYU70E81UB70673', ' '); INSERT INTO vehicles VALUES ('2008', 'MERCEDES-BENZ', 'ML320', ' ', '50543', 'Black', '35400', '4JGBB22E18A355249', ' '); INSERT INTO vehicles VALUES ('2011', 'CADILLAC', 'STS', 'AWD', '14028', 'Black', '42800', '1G6DD67V280199562', '5'); INSERT INTO vehicles VALUES ('1999', 'CADILLAC', 'ELDORADO', ' ', '58956', 'Black', '4350', '1G6EL12Y4XU607787', ' '); INSERT INTO vehicles VALUES ('2008', 'LAMBORGHINI', 'GALLARDO', 'SPYDER', '4895', 'Black', '139900', 'ZHWGU22T28LA06389', ' '); SELECT * from vehicles; SELECT COUNT(*) FROM vehicles; /* This command will count the number of vehicles that is in stock*/ SELECT AVG(Mileage) FROM vehicles; /*This command will operate the average mileage for the cars in the lot*/ SELECT SUM(Price) FROM vehicles; /*This command will calculate the total price of the vehicles that are sold*/ SELECT DISTINCT Make FROM vehicles ORDER BY Make ASC; /*This command will select only the Make column and sort them in alphabetical order*/ SELECT * FROM vehicles WHERE trim LIKE '%4X4%'; /*This command will print out the full information of the 4X4 regardless of the type*/ UPDATE vehicles SET Color = ‘TAUPE’ WHERE Vin = ‘FAHP2EW1AG163911’; /*This command will print out the updated color of the vehicle*/ SELECT Count(Color) FROM vehicles WHERE Color IN (SELECT Color FROM vehicles LIMIT 3); SELECT Color FROM vehicles LIMIT 3; /*This command will print out the top 3 colors in the table*/ SELECT name,license,sum(price) FROM vehicles JOIN customers on vehicles = customers GROUP BY name,license; CREATE TABLE luxury ( brand VARCHAR(20) ); INSERT INTO luxury VALUES ("LINCOLN"), ("CADILLAC"), ("LAMBORGHINI"); SELECT * FROM vehicles WHERE make IN (SELECT * FROM luxury);
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear