Workshop Question
Workshop Question
Day 2
1. Display the details of all the Customers.
2. Display the ID, type, number, and expiry year of all the credit cards in the
following format.
Credit Card ID Credit Card Type Credit Card Number Expiry Year
3. Display the customer ID and the account number of all the customers who
live in the Territory ID 4.
4. Display all the details of the sales orders that have a cost exceeding $2,000.
5. Display the sales order details of the product named 'Cable Lock'. Hint: The
Product ID for Cable Lock is 843.
6. Display the list of all the orders placed on June 06, 2004.
7. Display a report of all the orders in the following format.
8. Display a list of all the sales orders in the price range of $2,000 to $2,100.
9. Display the name, country region code, and sales year to date for the territory
with Territory ID as 1.
10. Display the details of the orders that have a tax amount of more than $10,000.
11. Display the sales territory details of Canada, France, and Germany.
12. Generate a report that contains the IDs of sales persons living in the territory
with Territory ID as 2 OR 4. The report is required in the following format.
13. Display the details of the Vista credit cards that are expiring in the year
2006.
14. Display the details of all the orders that were shipped after July 12, 2004.
15. Write a query to display the sales order ID, territory ID, month, and year of
order in the following format.
Day 3
16. Display the orders placed on July 01, 2001 that have a total cost of more
than $10,000 in the following format.
17. Display the details of the orders that have been placed by customers online.
18. Display the order ID and the total amount due of all the sales orders in the
following format. Ensure that the order with the highest price is at the top of the
list.
19. Display the order ID and the tax amount for the sales orders that are less
than $2,000. The data should be displayed in the ascending order.
20. Display the order number and the total value of the order in ascending
order of the total value.
21. Display the maximum, minimum, and the average rate of sales orders.
22. Display the total value of all the orders put together.
23. Display the Order ID of the top five orders based on the total amount due in
the year 2001.
24. Display the details of all the currencies that have the word 'Dollar' in their
name.
25. Display all territories whose names begin with 'N'.
26. Display the SalesPersonID, the TerritoryID, and the sales quota for those
sales persons who have been assigned a sales quota. The data should be
displayed in the following format.
28. You can place an order for more than one product. Display a report
containing the product ID and the total cost of products for the product ID whose
total cost is more than $10000.
29. The following SQL query containing the COMPUTE BY clause generates
errors. What are possible causes of such errors?
SELECT ProductID, LineTotal AS 'Total' FROM Sales.SalesOrderDetail
COMPUTE sum (LineTotal) BY ProductID.
Day 4
30. Display the top three sales persons based on the (highest) bonus.
31. Display the details of those stores, which have Bike in their name.
32. Display the total amount collected from the orders for eachby order
date.
33. Display the total unit price and the total amount collected after
selling the products, 774 and 777. In addition, calculate the total amount
collected from these two products.
34. Display the sales order ID and the maximum and minimum values of
the order based on the sales order ID. In addition, ensure that the order
amount is greater than $5,000.
35. A report containing the sales order ID and the average value of the
total amount, which is greater than $5,000, is required in the following format.
36. Display the different types of credit cards used for purchasing
products.
37. Display the customer ID, name, and sales person ID for all the
stores. According to the requirement, only first 15 letters of the customer name
should be displayed.
46. Write a query to display the sales person ID and territory names for all sales
persons. If a sales person does not belong to any territory, NULL should be
displayed.
47. Write a query to display the total amount due of all the sales orders rounded
off to a whole number. In addition, display the sales order ID and the type of
credit card through which the payment was made.
48. Write a query to display the order date along with the sales order ID and
territory name. The order date should be displayed in the dd/mm/yyyy format.
49. Write a query to display the order ID and the territory name of the orders
where the month of order is May and year is 2004.
50. Write a query to retrieve the details of the product locations where cost rate is
greater than 12. In addition, the locations need to be grouped into three groups,
and then ranked based on the cost rate in descending order.
51. Display all female employee names and their manager name. Even if an
employee does not have a manger, those employee name should appear in the
result
52. Display all single male employees and their address (including state name,
country name) who wereborn before the year : 1980
53. Which manager (name) has the most number of employees working under
him/her?
54. Which manager (name) has the most number of female employees working
under him/her?
55. Display the number of employees by each state (state name) – based on their
address.
56. Find the second highest salaried employee per their current rate. Hint: Use
CTE for finding the latest rate per employee
57. Display the following details assuming all employees worked 7 days a week
and 8 hrs per day:Employee ID, Employee Name, Total Salary drawn till date.
Hint : Use CTE / Correlated sub query
Day 5
60. Create a view which displays Employee names and addresses with
following columns
o EmployeeID
o Title
o FirstName
o MiddleName
o LastName
o Suffix
o JobTitle
o Phone
o EmailAddress
o EmailPromotion
o AddressLine1
o AddressLine2
o City
o StateProvinceName
o PostalCode
o CountryRegionName
o AdditionalContactInfo
61. Create a view which displays employee name, title, and current department
and other columns as below
o EmployeeID
o Title
o FirstName
o MiddleName
o LastName
o Suffix
o JobTitle
o Department Name
o GroupName Name
o StartDate
62. Create a batch that finds the average pay rate (latest) of the employees
and then lists the details of employees who have a pay rate less than the
average pay rate.
63. Create a batch that displays all the employee details where for the ‘Marital
Status’ column it should display “Married’ for ‘M’ and ‘Single’ for ‘S’ and others
as ‘Unknown’.
Day 6
64. Create a function that returns the shipment date of a particular order.
65. Create a function that returns the credit card number for a particular order.
66. Create a function that returns a table containing the ID and the name of the
customers who are categorized as individual customers (CustomerType = 'I').
The function will take one parameter. The parameter value can be either
Shortname or Longname. If the parameter value is Shortname, only the last
name of the customer will be retrieved. If the value is Longname, then the full
name will be retrieved.
67. Write a procedure to display all the employee details along with the
department details to they belong based on the employee designation entered
by the user.
Day 7
71. Set Transaction level isolation to snapshot and begin the transaction. Update the column
“ModifiedDate” to today’s date.
72. The management of AdventureWorks, Inc. has decided that no user should
be able to change the prices of the products. In addition, management wants
that all the attempts to change the price should be saved in a temporary table,
Temp. John, the database developer has been asked to make the significant
changes in the database to implement this policy. What can John do to
achieve the same?
73. The management of AdventureWorks, Inc. wants that whenever the pay
rate of an employee is modified, its effect on the monthly salary of the
employee should be displayed. John, a database developer at
AdventureWorks, has been asked to resolve this problem. Help John to find
out appropriate solution.
74. Write a trigger to display the magic tables (Inserted and Deleted) data
during a trigger execution.
75. Write a query to retrieve the list price of the products where the product
price is between $ 360.00 and $ 499.00 and display the price in the following
format. The list price of “Product Name” is “Price”