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.
| Author |
Topic |
|
esambath
Yak Posting Veteran
89 Posts |
Posted - 2009-04-10 : 08:30:04
|
| HiI have two table1st Table LP_UserManagementUserIdEmailUsernamePasswordUserTypeStatusThe UserType0=Admin1=User2=Expert2nd Table RatingRatingIdUserIdExpertIdCommendsPointsStatusDeletedsample datasUserId Email Username Password UserType Status1 admin@yahoo.com admin 123456 0 12 Sambath@yahoo.com sambath 123456 1 13 sathosh@yahoo.com sathosh 123456 1 14 Satheesh@yahoo.com Satheesh 123456 2 1RatingId UserId ExpertId Commends Points Status Deleted1 2 4 good 4 1 02 3 4 good 5 1 0I have display the record of Expert Ratingplease see my test queryselect U.Nickname,sum(r.points) as Total, sum(points)/count(U.UserId) as Avgrating from LP_Rating rjoin LP_UserManagement U on U.UserId=r.UserIdwhere r.Deleted=0 group by U.Nickname,r.pointsAnybody please advice me.How to get the resultThanks and RegardsSambath Kumar |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-04-10 : 09:40:51
|
just remove r.points from your GROUP BYselect U.Username ,sum(r.points) as Total ,avg(r.points) as Avgratingfrom LP_Rating rjoin LP_UserManagement U on U.UserId=r.UserIdwhere r.Deleted=0 group by U.Username Be One with the OptimizerTG |
 |
|
|
|
|
|