Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write SQL queries to produce the following results: 1) List all students and cou

ID: 3823077 • Letter: W

Question

Write SQL queries to produce the following results:

1)  List all students and courses they are registered for. Include, in this order, CustomerNumber, CustomerName, Phone, CourseNumber, and AmountPaid.

2) List the total amount paid for each course starting after July 4, 2009. Include, in this order, CourseNumber, CourseName, and total amount paid for that course.

3) List the average amount paid for each customer. Include, in this order, CustomerName and average amount paid by that customer.

4) List all students registered in the Adv. Pastels starting on October 1, 2009. Include, in this order, CourseName, CourseDate, Fee, CustomerName, and Phone.

COURSE CourseNumber Course CourseDate Fee 1 Adv Pastels 10/1/2009 $500.00 2 Beg Oils 9/15/2009 $350.00 3 Int Pastels 3/15/2009 $350.00 4 Beg Oils 10/15/2009 $350.00 5 Adv Pastels 11/15/2009 $500.00

Explanation / Answer


1) List all students and courses they are registered for.
Include, in this order, CustomerNumber, CustomerName, Phone, CourseNumber, and AmountPaid.

Query:

select Cust.CustomerNumber AS CustomerNumber,
Cust.CustomerFirstName AS CustomerName,
Cust.Phone AS Phone,
   Enrol.CourseNumber AS CourseNumber,
   Enrol.AmountPaid AS AmountPaid
from ENROLLMENT AS Enrol
INNER JOIN CUSTOMER AS Cust ON Enrol.CustomerNumber = Cust.CustomerNumber

2) List the total amount paid for each course starting after July 4, 2009.
Include, in this order, CourseNumber, CourseName, and total amount paid for that course.

Query:

Select
Enrol.CourseNumber AS CourseNumber,
Co.Course As CourseName,
SUM(Enrol.AmountPaid) As TotalAmountPaid
From
ENROLLMENT AS Enrol
INNER JOIN COURSE AS Co ON Enrol.CourseNumber = Co.CourseNumber
Where Co.CourseDate >= CONVERT(DATE,'7/04/2009')
Group By Enrol.CourseNumber,Co.Course

3) List the average amount paid for each customer.
Include, in this order, CustomerName and average amount paid by that customer.

Query:

select
Cust.CustomerFirstName AS CustomerName,
Avg(Enrol.AmountPaid) AS AverageAmountPaid
from ENROLLMENT AS Enrol
INNER JOIN CUSTOMER AS Cust ON Enrol.CustomerNumber = Cust.CustomerNumber
   Group By Cust.CustomerFirstName
     

4) List all students registered in the Adv. Pastels starting on October 1, 2009.
Include, in this order, CourseName, CourseDate, Fee, CustomerName, and Phone.

Query:

Select
Co.Course As CourseName,
Co.CourseDate As CourseDate,
Co.Fee As Fee,
Cust.CustomerFirstName AS CustomerName,
Cust.Phone AS Phone
From
ENROLLMENT AS Enrol
INNER JOIN COURSE AS Co ON Enrol.CourseNumber = Co.CourseNumber
INNER JOIN CUSTOMER AS Cust ON Enrol.CustomerNumber = Cust.CustomerNumber
Where Co.Course = 'Adv Pastels'
AND Co.CourseDate = CONVERT(DATE,'1/10/2009')

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote