Murach’s SQL for SQL Server – Exercise 11 – Guaranteed 100% score
1. Using the diagram and grid panes of the Query Designer, query the Vendors table for
vendors in California. The results pane should look like this:
2. Using the diagram and grid panes of the Query Designer, create a query that joins the
Vendors, Invoices, InvoiceLineItems, and GLAccounts tables. Filter the result set for
rows with AccountNo 553, and sort the result set with the most recent InvoiceDate
first.
3. Using the diagram and grid panes of the Query Designer, create a summary query
that joins Vendors and Invoices. For each vendor, return the number of invoices with
an outstanding balance and the sum of the outstanding balances. Determine whether
the search condition appears in the WHERE clause or the HAVING clause, then
change the grid pane to switch where it appears.
4. Use the Query Designer to create a SELECT INTO query that makes a copy of the
Invoices table called InvoiceCopy2. Then, use the Query Designer to insert a new
row into the InvoiceCopy2 table using the following values:
5. a. Use the Enterprise Manager to create a new database called Membership using
the default settings. (If the database already exists, use the Enterprise Manager to
drop it, then recreate it.)
b. Use the Enterprise Manager to create the following tables and relationships in
the Membership database. Define IndividualID and GroupID as IDENTITY
columns. Allow Address and Phone to accept null values; none of the other
columns should allow null values. Define the Dues column with a default of zero
and a check constraint to allow only positive values. Define the DuesPaid
column with a default Boolean value of False.
GroupID, int
GroupName, varchar
Dues, money
Groups
GroupID, int
IndividualID, int
GroupMembership
IndividualID, int
FirstName, varchar
LastName, varchar
Address, varchar
Phone, varchar
DuesPaid, bit
Individuals
c. Use the Enterprise Manager to index the GroupMembership table. Create a
clustered index on the GroupID column, a nonclustered index on the
IndividualID column, and a unique index and constraint on both columns.
d. Use the Enterprise Manager Database Designer window to create and print a
database diagram for the completed Membership database.