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)
 AVG on JOIN

Author  Topic 

vital101
Starting Member

4 Posts

Posted - 2008-04-21 : 12:35:57
Hey everyone,

I'm having trouble getting the average of the column data.answerID. Here's what I have so far.


SELECT data.answerID, questions.question, data.questionType
FROM dbo.data INNER JOIN
questions ON (data.questionID = questions.question_num) AND (data.questionType = 'serviceRequest')


I tried using a derived table but couldn't get it work. Any help would be much appreciated. Thanks!

/vital101

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2008-04-21 : 12:45:11
Something like this...

SELECT avg(data.answerID), questions.question, data.questionType
FROM dbo.data INNER JOIN
questions ON (data.questionID = questions.question_num) AND (data.questionType = 'serviceRequest')
group by questions.question, data.questionType

Post some sample data if this is way off the mark...


Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page

vital101
Starting Member

4 Posts

Posted - 2008-04-21 : 12:50:49
Seemed to work great. Thanks again!
Go to Top of Page
   

- Advertisement -