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 2000 Forums
 SQL Server Development (2000)
 Trouble Aggregating

Author  Topic 

Cyclonik
Posting Yak Master

114 Posts

Posted - 2001-03-14 : 18:09:48
I am having some trouble coming up with a solution for summing up data.

I have a test which is stored in 2 tables. one with the test info
testid|testee|tester|date|notes
and a table with the scores
testid|questionid|score

what i need is a record which returns the average score for each question id in its own column.
i am not sure if i can do this or not in one select statement.

i can do it easily for one particular question like this (obvious)...

SELECT AVG(c.Points) as CE1,
COUNT(distinct a.monitor_id) as TotalMonitors,
b.Fname,b.Lname,a.lanid
From tblVoice_MonitorsT a
JOIN tblUsersT b
ON a.lanid=b.lanid
JOIN tblVoice_monitor_scores_idx c
ON a.monitor_id=c.monitor_id
WHERE a.lanid = @id AND (a.monitor_date BETWEEN @datestart AND @dateend
OR a.monitor_date Is Null) and criteria_id = 1
GROUP BY b.Lname,b.Fname,a.lanid



Thanks in advance
Christian


-=:SpasmatiK:=-
   

- Advertisement -