SELECT min(Order_Quantity) ,  avg(Order_Quantity) ,  max(Order_Quantity) FROM INVOICES
What are the minimum, average, and maximum quantities ordered? Check all the invoices.
CREATE TABLE Ref_Payment_Methods (
payment_method_code CHAR(10) NOT NULL,
payment_method_description VARCHAR(80),
PRIMARY KEY (payment_method_code),
UNIQUE (payment_method_code)
);
CREATE TABLE Ref_Service_Types (
Service_Type_Code CHAR(15) NOT NULL,
Parent_Service_Type_Code CHAR(15),
Service_Type_Description VARCHAR(255),
PRIMARY KEY (Service_Type_Code),
UNIQUE (Service_Type_Code)
);
CREATE TABLE Addresses (
Address_ID VARCHAR(100) NOT NULL,
Line_1 VARCHAR(255),
Line_2 VARCHAR(255),
City_Town VARCHAR(255),
State_County VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Address_ID),
UNIQUE (Address_ID)
);
CREATE TABLE Products (
Product_ID VARCHAR(100) NOT NULL,
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
Product_Description VARCHAR(255),
Other_Product_Service_Details VARCHAR(255),
PRIMARY KEY (Product_ID),
UNIQUE (Product_ID)
);
CREATE TABLE Marketing_Regions (
Marketing_Region_Code CHAR(15) NOT NULL,
Marketing_Region_Name VARCHAR(255) NOT NULL,
Marketing_Region_Descriptrion VARCHAR(255) NOT NULL,
Other_Details VARCHAR(255),
PRIMARY KEY (Marketing_Region_Code),
UNIQUE (Marketing_Region_Code)
);
CREATE TABLE Clients (
Client_ID INTEGER NOT NULL,
Address_ID INTEGER NOT NULL,
Customer_Email_Address VARCHAR(255),
Customer_Name VARCHAR(255),
Customer_Phone VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Client_ID),
UNIQUE (Client_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID)
);
CREATE TABLE Drama_Workshop_Groups (
Workshop_Group_ID INTEGER NOT NULL,
Address_ID INTEGER NOT NULL,
Currency_Code CHAR(15) NOT NULL,
Marketing_Region_Code CHAR(15) NOT NULL,
Store_Name VARCHAR(255),
Store_Phone VARCHAR(255),
Store_Email_Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Workshop_Group_ID),
UNIQUE (Workshop_Group_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID)
);
CREATE TABLE Performers (
Performer_ID INTEGER NOT NULL,
Address_ID INTEGER NOT NULL,
Customer_Name VARCHAR(255),
Customer_Phone VARCHAR(255),
Customer_Email_Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Performer_ID),
UNIQUE (Performer_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID)
);
CREATE TABLE Customers (
Customer_ID VARCHAR(100) NOT NULL,
Address_ID INTEGER NOT NULL,
Customer_Name VARCHAR(255),
Customer_Phone VARCHAR(255),
Customer_Email_Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Customer_ID),
UNIQUE (Customer_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID)
);
CREATE TABLE Stores (
Store_ID VARCHAR(100) NOT NULL,
Address_ID INTEGER NOT NULL,
Marketing_Region_Code CHAR(15) NOT NULL,
Store_Name VARCHAR(255),
Store_Phone VARCHAR(255),
Store_Email_Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Store_ID),
UNIQUE (Store_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID),
FOREIGN KEY (Marketing_Region_Code) REFERENCES Marketing_Regions (Marketing_Region_Code)
);
CREATE TABLE Bookings (
Booking_ID INTEGER NOT NULL ,
Customer_ID INTEGER NOT NULL,
Workshop_Group_ID VARCHAR(100) NOT NULL,
Status_Code CHAR(15) NOT NULL,
Store_ID INTEGER NOT NULL,
Order_Date DATETIME NOT NULL,
Planned_Delivery_Date DATETIME NOT NULL,
Actual_Delivery_Date DATETIME NOT NULL,
Other_Order_Details VARCHAR(255),
PRIMARY KEY (Booking_ID),
UNIQUE (Booking_ID),
FOREIGN KEY (Customer_ID) REFERENCES Clients (Client_ID),
FOREIGN KEY (Workshop_Group_ID) REFERENCES Drama_Workshop_Groups (Workshop_Group_ID)
);
CREATE TABLE Performers_in_Bookings (
Order_ID INTEGER NOT NULL,
Performer_ID INTEGER NOT NULL,
PRIMARY KEY (Order_ID, Performer_ID),
FOREIGN KEY (Performer_ID) REFERENCES Performers (Performer_ID),
FOREIGN KEY (Order_ID) REFERENCES Bookings (Booking_ID)
);
CREATE TABLE Customer_Orders (
Order_ID INTEGER NOT NULL ,
Customer_ID INTEGER NOT NULL,
Store_ID INTEGER NOT NULL,
Order_Date DATETIME NOT NULL,
Planned_Delivery_Date DATETIME NOT NULL,
Actual_Delivery_Date DATETIME NOT NULL,
Other_Order_Details VARCHAR(255),
PRIMARY KEY (Order_ID),
UNIQUE (Order_ID),
FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID),
FOREIGN KEY (Store_ID) REFERENCES Stores (Store_ID)
);
CREATE TABLE Order_Items (
Order_Item_ID INTEGER NOT NULL ,
Order_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
Order_Quantity VARCHAR(288),
Other_Item_Details VARCHAR(255),
PRIMARY KEY (Order_Item_ID),
FOREIGN KEY (Order_ID) REFERENCES Customer_Orders (Order_ID),
FOREIGN KEY (Product_ID) REFERENCES Products (Product_ID)
);
CREATE TABLE Invoices (
Invoice_ID INTEGER NOT NULL,
Order_ID INTEGER NOT NULL,
payment_method_code CHAR(15),
Product_ID INTEGER NOT NULL,
Order_Quantity VARCHAR(288),
Other_Item_Details VARCHAR(255),
Order_Item_ID INTEGER NOT NULL,
PRIMARY KEY (Invoice_ID),
FOREIGN KEY (Order_ID) REFERENCES Customer_Orders (Order_ID),
FOREIGN KEY (Order_ID) REFERENCES Bookings (Booking_ID),
FOREIGN KEY (payment_method_code) REFERENCES Ref_Payment_Methods (payment_method_code)
);
CREATE TABLE Services (
Service_ID INTEGER NOT NULL,
Service_Type_Code CHAR(15),
Workshop_Group_ID INTEGER NOT NULL,
Product_Description VARCHAR(255),
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
Other_Product_Service_Details VARCHAR(255),
PRIMARY KEY (Service_ID),
UNIQUE (Service_ID),
FOREIGN KEY (Workshop_Group_ID) REFERENCES Drama_Workshop_Groups (Workshop_Group_ID),
FOREIGN KEY (Service_Type_Code) REFERENCES Ref_Service_Types (Service_Type_Code)
);
CREATE TABLE Bookings_Services (
Order_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
PRIMARY KEY (Order_ID, Product_ID),
FOREIGN KEY (Order_ID) REFERENCES Bookings (Booking_ID),
FOREIGN KEY (Product_ID) REFERENCES Services (Service_ID)
);
CREATE TABLE Invoice_Items (
Invoice_Item_ID INTEGER NOT NULL ,
Invoice_ID INTEGER NOT NULL,
Order_ID INTEGER NOT NULL,
Order_Item_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
Order_Quantity INTEGER,
Other_Item_Details VARCHAR(255),
PRIMARY KEY (Invoice_Item_ID),
FOREIGN KEY (Order_Item_ID) REFERENCES Order_Items (Order_Item_ID),
FOREIGN KEY (Invoice_ID) REFERENCES Invoices (Invoice_ID),
FOREIGN KEY (Order_ID, Product_ID) REFERENCES Bookings_Services (Order_ID,Product_ID)
);
INSERT INTO Ref_Payment_Methods (`payment_method_code`, `payment_method_description`) VALUES ('American E', 'credit');
INSERT INTO Ref_Service_Types ( `Service_Type_Code`,`Parent_Service_Type_Code`,`Service_Type_Description`) VALUES ('1','1','provide photo service');
INSERT INTO Addresses (`Address_ID`, `Line_1`, `Line_2`, `City_Town`, `State_County`, `Other_Details`) VALUES ('110', '4753 Dach Highway', 'Suite 846', 'Feliciaberg', 'Florida', NULL);
INSERT INTO Products (`Product_ID`, `Product_Name`, `Product_Price`, `Product_Description`, `Other_Product_Service_Details`) VALUES ('11', 'photo', '4448536.0000', NULL, NULL);
INSERT INTO Marketing_Regions (`Marketing_Region_Code`, `Marketing_Region_Name`, `Marketing_Region_Descriptrion`, `Other_Details`) VALUES ('CA', 'Canada', 'Our target market', NULL);
INSERT INTO Clients (`Client_ID`, `Address_ID`, `Customer_Email_Address`, `Customer_Name`, `Customer_Phone`, `Other_Details`) VALUES (423, 201, 'branson94@example.net', 'Clifford', '(042)912-3404x5135', 'VIP');
INSERT INTO Drama_Workshop_Groups (`Workshop_Group_ID`, `Address_ID`, `Currency_Code`, `Marketing_Region_Code`, `Store_Name`, `Store_Phone`, `Store_Email_Address`, `Other_Details`) VALUES (136, 383, 'EU', 'FR', 'Amely Cafe', '122-084-8029', 'amely.ruecker@example.com', NULL);
INSERT INTO Performers (`Performer_ID`, `Address_ID`, `Customer_Name`, `Customer_Phone`, `Customer_Email_Address`, `Other_Details`) VALUES (153, 124, 'Shawna', '664.495.1939', 'krogahn@example.com', NULL);
INSERT INTO Customers (`Customer_ID`, `Address_ID`, `Customer_Name`, `Customer_Phone`, `Customer_Email_Address`, `Other_Details`) VALUES ('240', 286, 'Harold', '624-096-7791', 'jerde.harmon@example.com', NULL);
INSERT INTO Stores (`Store_ID`, `Address_ID`, `Marketing_Region_Code`, `Store_Name`, `Store_Phone`, `Store_Email_Address`, `Other_Details`) VALUES ('150', 286, 'IN', 'FJA Filming', '+65(1)3590790358', 'fjacobson@example.com', NULL);
INSERT INTO Bookings (`Booking_ID`, `Customer_ID`, `Workshop_Group_ID`, `Status_Code`, `Store_ID`, `Order_Date`, `Planned_Delivery_Date`, `Actual_Delivery_Date`, `Other_Order_Details`) VALUES (1, 938, '140', 'good', 8, '2016-12-12 10:43:01', '2013-03-10 18:47:05', '1997-11-21 10:07:40', NULL);
INSERT INTO Performers_in_Bookings (`Order_ID`, `Performer_ID`) VALUES (1, 153);
INSERT INTO Customer_Orders (`Order_ID`, `Customer_ID`, `Store_ID`, `Order_Date`, `Planned_Delivery_Date`, `Actual_Delivery_Date`, `Other_Order_Details`) VALUES (1, 516, 231, '1994-08-03 12:34:58', '1977-03-11 03:58:19', '1992-07-21 22:11:11', NULL);
INSERT INTO Order_Items (`Order_Item_ID`, `Order_ID`, `Product_ID`, `Order_Quantity`, `Other_Item_Details`) VALUES (1, 3, 233, '1', NULL);
INSERT INTO Invoices (`Invoice_ID`, `Order_ID`, `payment_method_code`, `Product_ID`, `Order_Quantity`, `Other_Item_Details`, `Order_Item_ID`) VALUES (128, 14, 'MasterCard', 4, 2, NULL, 1);
INSERT INTO Services (`Service_ID`, `Service_Type_Code`, `Workshop_Group_ID`, `Product_Description`, `Product_Name`, `Product_Price`, `Other_Product_Service_Details`) VALUES (191, '1', 415, NULL, 'film', '58932775.8822', NULL);
INSERT INTO Bookings_Services (`Order_ID`, `Product_ID`) VALUES (1, 396);
INSERT INTO Invoice_Items (`Invoice_Item_ID`, `Invoice_ID`, `Order_ID`, `Order_Item_ID`, `Product_ID`, `Order_Quantity`, `Other_Item_Details`) VALUES (1, 128, 1, 5, 396, 2, NULL);