Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PostgreSQL/ PSQL ===============================================================

ID: 3812817 • Letter: P

Question

PostgreSQL/ PSQL

============================================================================

Question 13:

The required database is too long to be posted here. I could copy and paste it in the form, but I can't submit it because it is too long. The Northwind database (among others) is publicy available and free from Microsoft as a sample database...I guess that's why my teacher chose it so there wouldn't be any copyright infringement. Please use a search engine to find the database for the question above. I would rather just copy and paste a link for everyone to get it, but I don't know how Chegg would feel about that even though it is publicly available from Microsoft.

Thank you!

The database needed for this assignment is the North Wind database. Run the script in either PSQL or PG Admin. In PGAdmin, create the database Northwind, then double-click to open the database. Right click and choose create SCRIPT. In NotePad++, select the entire script and copy it. Paste it in the upper script window in PGAdmin. Click run To submit your answers, you may copy and paste your SQL statements into a Notepad document to submit. In PSQL, if you click on the icon in the upper left corner, you will get a menu and you can choose edit select all. If you copy (CNTRL-C and then paste into Notepad++, you will have a copy to paste/turn in. You may save it all to one file or you may copy pieces as you go along.

Explanation / Answer

List the Company name, contact name, contact title and the phone number for customers who live in USA and have placed an order.

SELECT C.CompanyName,C.Contact Name, C.ContactTitle, C.Phone FROM Customers C JOIN Orders O ON (C.CustomerID=O.Customer ID) WHERE O.OrderID IS NOT NULL;


Create a listing displaying the employee first name, last name and the full name(First name space Last Name) of the person they report to(Supervisor). If an employee does not report to anyone, they should not appear in the result set.

SELECT First Name, LastName, ReportsTo FROM Employees WHERE ReportsTo IS NOT NULL;


Create a summary query that will display the number of orders, the country name, the earliest order date, the latest order date by country for United States and Mexico.

SELECT Count(OrderID), ShipCountry, MIN(OrderDate), MAX(OrderDAte) From Orders Where ShipCountry = 'United States' OR ShipCountry = 'Mexico';

Make use of an aggregate function that will display the number of customers who are from Italy France or spain. There should be one row per country within the test result set.

SELECT Count(CustomerID), Country FROM Customers WHERE Country = 'ITALY' OR Country = 'SPAIN' OR Country = 'FRANCE' GROUP BY Country;

List the total quantity ordered for all product that have a category of Beverages.

SELECT SUM(O.Quantity) FROM ORDER DETAILS O JOIN PRODUCTS P JOIN CATEGORIES C ON (C.CategoryID = P.categoryID) AND (P.ProductID = O.ProductID) WHERE C.CategoryName = 'Beverages';

You are to create a query that will display the number of orders grouped by city. This should only list cities where number of orders are over 20.

SELECT Count(OrderID) FROM Orders WHERE Count(Order ID)>20 GROUP BY ShipCity;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote