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 2005 Forums
 Transact-SQL (2005)
 root mean square formula in SQL

Author  Topic 

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2007-05-11 : 03:28:52
Hi,

I'm wondering if anyone knows anything about root mean square and how to best accomplish it in SQL ? Also if anyone would agree this is a good solution to a feedback rating system that is polluted by often getting 1's and 10's.

I have a query that brings back results in this format


Column:10/20/30/40/50/60/70/80/90/100/Total

Row 1 :81/5 /4 /5 /4 /4 /15/10/20/321/537



Here is the query, I am looking to add 1 additional column "RMS" (which would be the calculated Root Mean Square")


Thanks very much for any assistance!
mike123




SELECT

ISNULL(SUM ( CASE WHEN points = 10 THEN 1 ELSE 0 END ),0) as '10',
ISNULL(SUM ( CASE WHEN points = 20 THEN 1 ELSE 0 END ),0) as '20',
ISNULL(SUM ( CASE WHEN points = 30 THEN 1 ELSE 0 END ),0) as '30',
ISNULL(SUM ( CASE WHEN points = 40 THEN 1 ELSE 0 END ),0) as '40',
ISNULL(SUM ( CASE WHEN points = 50 THEN 1 ELSE 0 END ),0) as '50',
ISNULL(SUM ( CASE WHEN points = 60 THEN 1 ELSE 0 END ),0) as '60',
ISNULL(SUM ( CASE WHEN points = 70 THEN 1 ELSE 0 END ),0) as '70',
ISNULL(SUM ( CASE WHEN points = 80 THEN 1 ELSE 0 END ),0) as '80',
ISNULL(SUM ( CASE WHEN points = 90 THEN 1 ELSE 0 END ),0) as '90',
ISNULL(SUM ( CASE WHEN points = 100 THEN 1 ELSE 0 END ),0) as '100',

COUNT(*) AS TotalVotes FROM tblUserVote








CREATE TABLE [dbo].[tblUserVote](
[voteID] [int] IDENTITY(1,1) NOT NULL,
[points] [tinyint] NOT NULL
)





   

- Advertisement -