Skip navigation

T-SQL Tutor Project, December 2002

Download the Code iconHere’s a small homework assignment to help you continue to improve your ability to create and access views. When you’re just learning how to create views, the hardest part is writing the query. The test query in this assignment accesses the Products and Categories tables in the Northwind sample database.

First, write a query that gathers a list of the top 10 beverages that have the most units in stock. You can use the UnitsInStock column from the Products table to find which products have the highest UnitsInStock values. Make sure to list the ProductName, UnitPrice, UnitsInStock, and QuantityPerUnit columns. Then, name the view BeveragesTopInStockView.

You can find the answers to this assignment in the ViewsPartIHomeworkAnswers.sql script file, which you can download by clicking the Download the Code button. After you’ve finished your homework, start applying the tools and tips I gave you in the main article to gather data about user access to your databases. When you check to see whether your views are being used properly, you might be surprised at what you find.

TAGS: SQL
Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish