Yong Kevin

Yong Kevin

  • NA
  • 35
  • 2.1k

Get the Average Score and display

Jan 28 2021 3:05 PM
Hi everyone,
 
I have a question on the TSQL Syntax.
 
Now, I have 2 table which is Service & Rating:
Service:
Rating: 
 
As you can see, the Rating_Id in the Rating table has many Services_Id values = 1
 
Now I want to get the Average Rating Score and display on the webpage, the TSQL that I tried:
  1. SELECT AVG(r.Score),s.*  
  2. FROM Services s    
  3. FULL OUTER JOIN Rating r ON r.Services_Id = s.Services_Id   
  4. GROUP BY s.Services_id, r.Services_Id  
 As I want to display, all the services that have and do not have ratings and for those that have ratings, I want to calculate Average Rating score.
 
How can I achieve that
 
Please help
 
Thank you 
 
 

Answers (8)