Workshop

The Workshop provides quiz questions to help you solidify your understanding of the material covered and exercises to provide you with experience in using what you've learned. Try to answer the quiz and exercise questions before checking the answers in Appendix A, "Answers to Quizzes and Exercises," and make sure that you understand the answers before continuing to the next lesson.

Quiz

1:Put the following keywords in order to make a SELECT statement work properly:
  • GROUP BY

  • HAVING

  • SELECT

  • DISTINCT

  • WHERE

  • FROM

  • ORDER BY

  • ROLLUP

2:What is the difference between COUNT(*) and COUNT(expression)?
3:Is the following query permitted? If not, how would you correct it?
select ProductID, ProductName
  from Products
 where UnitPrice > avg(UnitPrice)

4:Is the following query permitted? If not, how would you correct it?
select Country, Region, Count(*) as 'Customers'
  from Customers
 group by Country

5:What is the difference between HAVING and WHERE?
6:What is the difference between ROLLUP and CUBE?

Exercises

1:Who is the oldest employee, and when was he or she born?
2:How many customers are located outside the United States?
3:Prepare a report showing a breakdown of suppliers by country. Include a grand total in the report.
Country         Suppliers
--------------- -----------
Australia                 2
Brazil                    1
Canada                    2
Denmark                   1
Finland                   1
France                    3
Germany                   3
Italy                     2
Japan                     2
Netherlands               1
Norway                    1
Singapore                 1
Spain                     1
Sweden                    2
UK                        2
USA                       4
NULL                     29

4:Which countries have more than one supplier? Sort the countries by greatest to least occurrence.
Country         Suppliers
--------------- -----------
USA                       4
France                    3
Germany                   3
Australia                 2
Canada                    2
Italy                     2
Japan                     2
Sweden                    2
UK                        2

5:How many different categories of product are there?
6:Display the top selling product ID (by dollars sold, including discounts) and the total dollar sales.
ProductID   Dollar Sales
----------- -------------------------------
         38               41396.73522949219

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset