Question
Given these tables: ClientID ClientName ClientEmail ClientPhone ClientState ClientCountry lawyerID 321 John Doe Doe@xxxxx.com 3013218295 Maryland United State 123 654 Jane Doe Jdoes@xxxxx.com 3013218296 Maryland
Given these tables:
ClientID
ClientName | ClientEmail | ClientPhone | ClientState | ClientCountry | lawyerID | |
321 | John Doe | Doe@xxxxx.com | 3013218295 | Maryland | United State | 123 |
654 | Jane Doe | Jdoes@xxxxx.com | 3013218296 | Maryland | United State | 456 |
987 | Todd Suit | Todd@xxxxx.com | 3013218297 | Maryland | United State | 789 |
Lawyers Table:
lawyerID | lawyerName | lawyerEmail | lawyerPhone | lawyerState | lawyerCountry |
123 | Ally McBeal | McBeal@lawfirm.com | 3013558295 | Maryland | United State |
456 | Perry Mason | Mason@lawfirm.com | 3013558296 | Maryland | United State |
789 | Atticus Finch | Atticus@lawfirm.com | 3013558297 | Maryland | United State |
Services Table:
ServiceID | CaseType | CaseHours | CaseTotal | ClientID |
100 | accident | 50 | 50 | 321 |
200 | divorce | 100 | 150 | 654 |
300 | tort | 40 | 80 | 987 |
I want to Create a view named ACCIDENT_TORT_CASES_V that lists only the client names, CaseType, and ServiceID for accident and tort cases only. Using a AVG function to calculate the average CaseHours for accident and tort cases.
Here is what I have, but it is not working. Can you help please?
CREATE VIEW ACCIDENT_TORT_CASES_V AS SELECT ClientName, s.CaseType, s.ServiceID, AVG (CaseHours) AS Average_CaseHours
FROM Client c
INNER JOIN Services s ON c.ClientID=s.ClientID
WHERE c.CaseType = accident
OR c.CaseType = tort;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started