W24 - Group 5 - PROG8651 - Group Project 1

docx

School

Conestoga College *

*We aren’t endorsed by this school

Course

1970

Subject

Computer Science

Date

Apr 3, 2024

Type

docx

Pages

12

Uploaded by BaronWater41457

Report
PROG8651 SQL Queries & Output PROG8651 – SECTION F GROUP MEMBER NAMES (A SHWIN R AMAKUMAR N AIR , H ET P ATEL , M EHAKDEEP K AUR , T ZU -C HIEN H UNG ) DATE: 02/02/2024 CONESTOGA COLLEGE – PROGRAM 1372 DANIEL HUNG
A SHWIN R AMAKUMAR N AIR , H ET P ATEL , M EHAKDEEP K AUR , T ZU -C HIEN H UNG PROG8651 2/02/24 Question #1: 1) Within the PRODUCT schema, show all records from the Product.Category table. SQL Query SELECT * FROM CATEGORY ; Snippet of output Question #2: Within the ORDERS schema, show all data from the CustomerOrder and ShipmentMethod tables:  Only show records where there are row matches between the PK and FK fields.  The join of equality (“equijoin”) must be listed in the WHERE statement. SQL Query SELECT * FROM CUSTOMERORDER AS C JOIN SHIPMETHOD S ON C . ShippingMethodID = S . ShippingMethodID ; Snippet of output
A SHWIN R AMAKUMAR N AIR , H ET P ATEL , M EHAKDEEP K AUR , T ZU -C HIEN H UNG PROG8651 2/02/24 Question #3: 3) Within the Orders schema, without using a WHERE statement, write a single SQL statement that shows the following data:  From the CustomerOrder table, show the OrderID and TotalPaid.  From the ShipmentMethod table, show the shipment mode.  Hint, you’ll need to make use of the ‘ON’ command. SQL Query SELECT OrderID , TotalPaid , S . ShipmentMode FROM CUSTOMERORDER AS C JOIN SHIPMETHOD S ON C . ShippingMethodID = S . ShippingMethodID ; Snippet of output
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
A SHWIN R AMAKUMAR N AIR , H ET P ATEL , M EHAKDEEP K AUR , T ZU -C HIEN H UNG PROG8651 2/02/24 Question #4: 4) Within the Orders schema, display all orders from the CustomerOrder table that have a total amount paid that is less than $1,000 Canadian dollars.  Display all the fields from the CustomerOrder table in your output. SQL Query SELECT * FROM CUSTOMERORDER WHERE TotalPaid < 1000 ; Snippet of output Question #5: 5) Within the Orders schema, display shipment method records where EsƟmated date shipped is the same as the actual date shipped. SQL Query SELECT * FROM SHIPMETHOD S JOIN CUSTOMERORDER C ON S . ShippingMethodID = C . ShippingMethodID WHERE C . EstDateShipped = C . ActualDateShipped ; Snippet of output
A SHWIN R AMAKUMAR N AIR , H ET P ATEL , M EHAKDEEP K AUR , T ZU -C HIEN H UNG PROG8651 2/02/24 Question #6: 6) Within the Orders schema, list the OrderID for all orders that have an order status of either in transit, or delayed. SQL Query SELECT C . OrderID FROM CUSTOMERORDER C JOIN ORDERSTATUS O ON C . OrderStatusID = O . OrderStatusID WHERE O . Description = 'In transit' OR O . Description = 'Delayed' ; Snippet of output Question #7: Within the PRODUCT schema , list the descripƟon for all products that have a product review raƟng of 4 or higher . SQL Query SELECT P . Description FROM PRODUCT P JOIN REVIEW R ON P . ProductID = R . ProductID WHERE R . Rating >= 4 ; Snippet of output
A SHWIN R AMAKUMAR N AIR , H ET P ATEL , M EHAKDEEP K AUR , T ZU -C HIEN H UNG PROG8651 2/02/24 Question #8: Within the Orders schema, list the total number of orders grouped by the different types of shipment modes. SQL Query SELECT COUNT ( C . OrderID ) AS TotalNumberOfOrders , S . ShipmentMode FROM CUSTOMERORDER C JOIN SHIPMETHOD S ON C . ShippingMethodID = S . ShippingMethodID GROUP BY S . ShipmentMode ; Snippet of output Question #9: 9) Within the PRODUCT and Orders schema, list all product details for products that have are not included on any order. SQL Query SELECT PRODUCT .* FROM PRODUCT WHERE PRODUCTID IN ( SELECT PRODUCT . ProductID FROM PRODUCT EXCEPT SELECT PRODUCTSELECTION . ProductID FROM PRODUCTSELECTION ) ; Snippet of output
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
A SHWIN R AMAKUMAR N AIR , H ET P ATEL , M EHAKDEEP K AUR , T ZU -C HIEN H UNG PROG8651 2/02/24 Question #10: Within the Orders schema, Display OrderID and CustomerID for any orders that have an actual shipping date that occurred in the month of September. SQL Query SELECT C . OrderID , C . CustomerID FROM CUSTOMERORDER C WHERE ActualDateShipped LIKE '%%%%-09-%%' ; Snippet of output Question #11: Within the Orders schema, Display OrderID and CustomerID for any orders that have an esƟmated shipping date that occurred before the year of 2022 SQL Query SELECT OrderID , CustomerID FROM CUSTOMERORDER WHERE YEAR ( EstDateShipped ) < 2022 ; Snippet of output
A SHWIN R AMAKUMAR N AIR , H ET P ATEL , M EHAKDEEP K AUR , T ZU -C HIEN H UNG PROG8651 2/02/24 Question #12: Within the Orders schema, Display OrderID and CustomerID for any orders that have an actual shipping date that occurred in the month of October but did not occur in the Year of 2023. SQL Query SELECT OrderID , CustomerID FROM CUSTOMERORDER WHERE MONTH ( ActualDateShipped ) = 10 AND YEAR ( ActualDateShipped ) != 2023 ; Snippet of output Question #13: Within the PRODUCT schema, list the item with the greatest (highest) price. SQL Query SELECT * FROM PRODUCT WHERE Price = ( SELECT MAX ( Price ) FROM PRODUCT ); Snippet of output
A SHWIN R AMAKUMAR N AIR , H ET P ATEL , M EHAKDEEP K AUR , T ZU -C HIEN H UNG PROG8651 2/02/24 Question #14: Within the Orders schema, using only the ProductSelecƟon table, display the three Orders that have the greatest (highest) prices, grouped by OrderID. SQL Query SELECT TOP 3 P . OrderID , SUM ( P . UnitPriceSold ) AS TotalUnitPrice FROM PRODUCTSELECTION P GROUP BY OrderID ORDER BY TotalUnitPrice DESC ; Snippet of output Question #15: 15) Within the Orders schema, count the total number of products that have been purchased on all orders - Do not group orders SQL Query SELECT COUNT ( ProductID ) AS TotalNumberOfProductPurchased FROM PRODUCTSELECTION ; Snippet of output
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
A SHWIN R AMAKUMAR N AIR , H ET P ATEL , M EHAKDEEP K AUR , T ZU -C HIEN H UNG PROG8651 2/02/24 Question #16: 16) Within the Orders schema, count the number of orders placed by each customer.  The number of items per order is irrelevant.  Do not use a JOIN or subquery. SQL Query SELECT COUNT ( OrderID ) AS NumberOfOrders FROM CUSTOMERORDER GROUP BY CustomerID ; Snippet of output Question #17: 17) Within the PRODUCT schema, show the product informaƟon for any product that has a review raƟng between 3 and 5 with a product category name of either Perishable or Miscellaneous.  You must uƟlize one, or more, subqueries for your response.  You cannot use a JOIN anywhere within your query. SQL Query SELECT * FROM PRODUCT WHERE ProductID IN ( SELECT ProductID FROM REVIEW WHERE Rating BETWEEN 3 AND 5 ) AND ProductCategoryID IN ( SELECT ProductCategoryID FROM CATEGORY WHERE CategoryName IN ( 'Perishable' , 'Miscellaneous' ) ); Snippet of output
A SHWIN R AMAKUMAR N AIR , H ET P ATEL , M EHAKDEEP K AUR , T ZU -C HIEN H UNG PROG8651 2/02/24 Question #18: 18) Within the PRODUCT and Orders schema, show orders that include any products that were packaged in a giŌ box.  You must uƟlize one, or more, subqueries for your response.  You cannot use a JOIN anywhere within your query. SQL Query SELECT OrderID FROM CUSTOMERORDER WHERE CUSTOMERORDER . OrderID IN ( SELECT OrderID FROM PRODUCTSELECTION WHERE PRODUCTSELECTION . ProductID IN ( SELECT ProductID FROM PRODUCT WHERE Package = 'Gift box' )) Snippet of output Question #19: 19) Within the ORDERS and PRODUCT schema, show any order [OrderID] and Customer [CustomerID] where there is a single item which has a weight greater than 1 kilogram.  Evaluate the weight of each item independently, not the combined weight.  Consider all possibiliƟes. SQL Query SELECT OrderID , CustomerID FROM CUSTOMERORDER WHERE CUSTOMERORDER . OrderID IN ( SELECT OrderID FROM PRODUCTSELECTION WHERE PRODUCTSELECTION . ProductID IN ( SELECT ProductID FROM PRODUCT WHERE ( WeightUnits = 'Kilogram' AND WeightQTY >= 1 ) OR ( WeightUnits = 'Gram' AND WeightQTY >= 1000 ) )) ; Snippet of output
A SHWIN R AMAKUMAR N AIR , H ET P ATEL , M EHAKDEEP K AUR , T ZU -C HIEN H UNG PROG8651 2/02/24 Question #20: 20) Within the ORDERS and PRODUCT schemas, for each Customer Order, display the OrderID, CustomerID, ProductID and the DescripƟon for each of the products. SQL Query SELECT C . OrderID , C . CustomerID , P . ProductID , PR . Description FROM CUSTOMERORDER C JOIN PRODUCTSELECTION P ON C . OrderID = P . OrderID JOIN PRODUCT PR ON P . ProductID = PR . ProductID ; Snippet of output
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help