# Sql exercise | Computer Science homework help

SQL Exercise (Due 2/22/2016 at the end of class)

Don't use plagiarized sources. Get Your Custom Essay on
Need an answer from similar question? You have just landed to the most confidential, trustful essay writing service to order the paper from.
Just from \$11/Page

Using Microsoft Access and the Northwind sample database, produce an SQL statement for each of the 4 exercises below. For each exercise you should submit both the SQL statement you have written along with a screen shot of the results.

*Important – Do Not Use the Query Wizard as these are exercises in learning to write SQL.  It will be apparent in the syntax if you completed the assignment with the Query Wizard.  Please practice honesty and integrity as you complete the assignment.

#1)  Number of Orders with Credit Card Payment

Write a SQL statement that will count the number of orders in the [Order Details] table that were paid by credit card.

Example:

SELECT [field], count(1)

FROM [table]

WHERE [field] = “value”

GROUP BY [field]

<Paste SQL Statement Here>

<Insert Result Image Here>

#2)  Top Selling Product based on Order Amount (One Join)

Write a SQL statement that will join the [Order Details ] table and [Products] table to determine the top selling product based on [Quantity]*[Unit Price].

Example:

SELECT B.[field], sum(A.[field]*A.[field]) as Orders

FROM ( [table] A

INNER JOIN [table] B

on A.[field] = B.[field] )

GROUP BY B.[field]

ORDER BY sum(A.[field] *A.[field] ) desc

<Paste SQL Statement Here>

<Insert Result Image Here>

#3)  Products with Less Than \$2500 in Orders

Write a SQL statement that will join the [Order Details] table and [Products] table to determine only those products with less than \$2500 in Orders based on [Quantity]*[Unit Price].

Example:

SELECT B.[field], sum(A.[field] * A.[field]) as Orders

FROM ([table] A

INNER JOIN [table] B

on A.[field] = B.[field])

GROUP BY B.[field]

HAVING sum(A.[field]*A.[field]) < value

ORDER BY sum(A.[field] *A.[field]) desc

<Paste SQL Statement Here>

<Insert Result Image Here>

#4) Top Producing Employee base on Order Amount (Two Joins)

Write a SQL statement that will join the [Orders] table, [Order Details] table and [Employees] table to determine the highest producing employee based on the employees first name and [Quantity]*[Unit Price].

Example:

SELECT C.[field], sum(A.[field] *A.[field] ) as Orders

FROM (([table] A

INNER JOIN [table] B

on A.[field] = B.[field])

INNER JOIN [table] C

on B.[field] = C.[field])

GROUP BY C.[field]

ORDER BY sum(A.[field] *A.[field] ) desc

<Paste SQL Statement Here>

<Insert Result Image Here>