Question

In: Computer Science

1. For each of the following, write a single SELECT query against the TSQLV4 database that...

1. For each of the following, write a single SELECT query against the TSQLV4 database that returns the result set described. Each of these queries involves two tables and can be written using a join operation.

a. One row for each order shipped to France or Germany, showing the order ID, the last name of the employee for the order, and the customer ID for the order.

b. One row for each employee who handled orders to Belgium, showing the employee’s initials (for example, for an employee named Yael Peled, this would be YP) and the number of orders that employee handled that were shipped to Belgium.

c. Same as part b., but include a row for every employee in the HR.Employees table, even if they did not handle any orders shipped to Belgium. (The number of orders for such an employee should be 0.)

Solutions

Expert Solution

a.

Select Sales.Orders.orderid, HR.Employees.lastname , Sales.Customers.custid from Sales.Orders inner join HR.Employees on Sales.Orders.empid = HR.Employees.empid inner join Sales.Customers on Sales.Orders.custid = Sales.Customers.custid where shipcountry = 'France' or shipcountry = 'Germany';

b.

Select HR.Employees.empid,CONCAT(substring(firstname,1,1) , substring(lastname,1,1)) as EmployeeInitials , count(Orders.orderid) as NumOfOrders from Sales.Orders inner join HR.Employees on Sales.Orders.empid = HR.Employees.empid group by HR.Employees.empid having shipcountry = 'France' or shipcountry = 'Belgium';

c.

Select HR.Employees.empid,CONCAT(substring(firstname,1,1) , substring(lastname,1,1)) as EmployeeInitials , count(Orders.orderid) as NumOfOrders from Sales.Orders right inner join HR.Employees on Sales.Orders.empid =HR.Employees.empid group by HR.Employees.empid having shipcountry = 'France' or shipcountry = 'Belgium';

Do ask if any doubt. Please upvote.


Related Solutions

Please write the correct query for the following questions: Select the name of each manufacturer along...
Please write the correct query for the following questions: Select the name of each manufacturer along with the name and price of its most expensive product. Computer products are expensive. Find the maximum priced product. Which products are within $30 of the maximum priced product. Find the maker of the most expensive ‘drive’. Note, there are variety of drives in the data. Regular expressions help. Using the following table: CREATE TABLE manufacturers ( code number PRIMARY KEY NOT NULL, name...
1.write about your plan for the database performance tuning, query optimization, and distributed database management systems.  Include...
1.write about your plan for the database performance tuning, query optimization, and distributed database management systems.  Include appropriate diagrams.
Describe what each line does in the following SQL query The lyrics database is provided under...
Describe what each line does in the following SQL query The lyrics database is provided under question 3 for context 1. select studioID, studioname, base from salespeople sa inner join studios st on (sa.salesID = st.salesid) where base < 300 2. select concat_ws(' ', firstname, lastname) as "Member Name"         from members; 3. select m.lastname, m.firstname, s.lastname         from members m inner join salespeople s using (salesID)         order by m.lastname asc; The lyrics database is provided below DROP TABLES...
1. Write a query to: a. select data from INVOICES table as follows: Invoice date in...
1. Write a query to: a. select data from INVOICES table as follows: Invoice date in MM/DD/YYYY format Invoice Date in DD-Mon-YYYY format Invoice Total rounded to the nearest dollar Note: you can alias columns as you sit fit b. select data from VENDORS table as follows: Vendor Name Concatenate Vendor Name with the string ‘s Address Concatenate Vendor City, Vendor State and Vendor Zip Code (alias this) Your output should look like this (this is just an example of...
Write a query to display the columns listed below. For each customer the query should show...
Write a query to display the columns listed below. For each customer the query should show the current system date, the current day (when you do the problem the date and day will be different), the number of characters in the member last name, the last date the customer rented a video and how many total videos the person rented. /* Database Systems, 9th Ed., Coronel/MOrris/Rob */ /* Type of SQL : MySQL */ CREATE SCHEMA IF NOT EXISTS TINY_VIDEO;...
Choose all the optional query block in “Select “retrieval query? A. Select B. Where C. From...
Choose all the optional query block in “Select “retrieval query? A. Select B. Where C. From D. Order By A NULL value means A. Value missing B. Value unknown C. More than 1000 D. All the above Delete from DEF; /*DEF is a table/relation*/ What action does this command perform? A. Delete the table B. Delete all the rows from the table C. Deletes a column D. Deletes the top 10 tuples A attribute/column, fName, is of Data Type varchar(100)....
SQL query exercises: Consider the following database schema:                Product(maker, model, type)              &
SQL query exercises: Consider the following database schema:                Product(maker, model, type)                PC(model, speed, ram, hd, rd, price)                Laptop(model, speed, ram, hd, screen, price)                Printer(model, color, type, price) Consider the Drivers-Cars-Reserves DB for a small rental car company:                Drivers(id, name, rating, age)                Cars(vin, maker, model, year, color)                Reserves(did, vin, date) Give SQL statement each of the following operations: Find the colors of cars reserved by Smith. Find all id’s of drivers who have a...
Which of the following is a Website query?Select all that apply.True False [Miami weather],...
Which of the following is a Website query?Select all that apply.True False [Miami weather],English (US) True False [Miami wikipedia.org],English (US) True False [Miami map],English (US) True False[Miami images], English (US)
Write a single C++ statement to accomplish each of the following.                               &nbs
Write a single C++ statement to accomplish each of the following.                                                  (6 pts) Read an integer from the user at the keyboard and store the value entered in an integer variable age. Compute the product of the 3 integers contained in variables x, y and z and assign the result to the variable result
What is a Data Dictionary? What is a Database Engine? What is a Query Processor/Analyzer? What...
What is a Data Dictionary? What is a Database Engine? What is a Query Processor/Analyzer? What is a Forms Generator? What is a Reports writer? What is a DBMS? What is the difference between DB and DBMS?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT