Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Multiple criteria Rating

Author  Topic 

jasmen
Starting Member

11 Posts

Posted - 2014-04-19 : 09:55:37
Hi i am making multiple criteria rating for doctors from Knowledge,Helpfulness,Punctuality,Staff
i made table called DoctorsRatings
Doctorid int
TotalRating int
StaffRating int
PunctualRating int
KnowledgeRating int
HelpfulnessRating int
i have many users can rate one doctor so i have to sum(StaffRating,PunctualRating,PunctualRating,KnowledgeRating,HelpfulnessRating) and put the sum result in TotalRating and get avg of TotalRating or what ???
last thing every criteria it rated from 1 to 5

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-04-19 : 10:33:08
[code]
Update DR
Set TotalRating = StaffRating + PunctualRating + KnowledgeRating + HelpfulnessRating,
AverageRating = (StaffRating + PunctualRating + KnowledgeRating + HelpfulnessRating) / 4.0
From DoctorsRatings DR
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

jasmen
Starting Member

11 Posts

Posted - 2014-04-19 : 11:03:43
quote:
Originally posted by khtan


Update DR
Set TotalRating = StaffRating + PunctualRating + KnowledgeRating + HelpfulnessRating,
AverageRating = (StaffRating + PunctualRating + KnowledgeRating + HelpfulnessRating) / 4.0
From DoctorsRatings DR



KH
[spoiler]Time is always against us[/spoiler]





thanks but if
Rate StaffRating PunctualRating KnowledgeRating HelpfulnessRating totalrate
user1 2 5 1 3 2.75
user2 2 2 2 2 4

i will select AVG(TotalRating)???
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-04-19 : 22:27:29
it depends on what you want.

You want average rating for all users then it is AVG(TotalRating)

if you want average rating for a user then it is sum of all rating for a user and divide by no of ratings


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -