Exercises

This section provides exercises to help you familiarize yourself with the subjects discussed in this chapter. The sample database TSQLFundamentals2008 is used in all exercises in this chapter.

1

Write a query that returns all orders placed on the last day of activity that can be found in the Orders table.

Tables involved: Sales.Orders table.

Desired output:

orderid     orderdate                   custid      empid
----------- --------------------------- ----------- -----------
11077       2008-05-06 00:00:00.000     65          1
11076       2008-05-06 00:00:00.000     9           4
11075       2008-05-06 00:00:00.000     68          8
11074       2008-05-06 00:00:00.000     73          7

2 (Optional, Advanced)

Write a query that returns all orders placed by the customer(s) who placed the highest number of orders. Note that more than one customer ...

Get Microsoft® SQL Server® 2008 T-SQL Fundamentals now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.