Generation

text to sql syntaxThu, 24 Nov 2022

CREATE TABLE Manufacturers with following data types:- Code INTEGER, Name VARCHAR(255) NOT NULL, CREATE TABLE Products with following data types:- Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, INSERT following data INTO Manufacturers table :- 1,'Sony' 2,'Creative Labs' 3,'Hewlett-Packard' 4,'Iomega' 5,'Fujitsu' 6,'Winchester' INSERT following data INTO Products table 1,'Hard drive',240,5 2,'Memory',120,6 3,'ZIP drive',150,4 4,'Floppy disk',5,6 5,'Monitor',240,1 6,'DVD drive',180,2 7,'CD drive',90,2 8,'Printer',270,3 9,'Toner cartridge',66,3 10,'DVD burner',180,2 -- 1.1 Select the names of all the products in the store. -- 1.2 Select the names and the prices of all the products in the store. -- 1.3 Select the name of the products with a price less than or equal to $200. -- 1.4 Select all the products with a price between $60 and $120. -- 1.5 Select the name and price in cents (i.e., the price must be multiplied by 100). -- 1.6 Compute the average price of all the products. -- 1.7 Compute the average price of all products with manufacturer code equal to 2. -- 1.8 Compute the number of products with a price larger than or equal to $180. -- 1.9 Select the name and price of all products with a price larger than or equal to $180, and sort first by price (in descending order), and then by name (in ascending order). -- 1.10 Select all the data from the products, including all the data for each product's manufacturer. -- 1.11 Select the product name, price, and manufacturer name of all the products. -- 1.12 Select the average price of each manufacturer's products, showing only the manufacturer's code. -- 1.13 Select the average price of each manufacturer's products, showing the manufacturer's name.

CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL, Price DECIMAL NOT NULL, Manufacturer INTEGER NOT NULL ); INSERT INTO Manufacturers VALUES (1,'Sony'), (2,'Creative Labs'), (3,'Hewlett-Packard'), (4,'Iomega'), (5,'Fujitsu'), (6,'Winchester'); INSERT INTO Products VALUES (1,'Hard drive',240,5), (2,'Memory',120,6), (3,'ZIP drive',150,4), (4,'Floppy disk',5,6), (5,'Monitor',240,1), (6,'DVD drive',180,2), (7,'CD drive',90,2), (8,'Printer',270,3), (9,'Toner cartridge',66,3), (10,'DVD burner',180,2); -- 1.

Questions about programming?Chat with your personal AI assistant