| Author |
Topic |
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-03-31 : 06:12:49
|
| SELECT ID, CalibScoreAVGQA, COUNT(CalibScoreAVGQA) AS Expr1FROM dbo.TechPhonesCalibScoreAVGQAAny idea why I'm getting "dbo.TechPhonesCalibScoreAVGQA.ID is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2008-03-31 : 06:15:26
|
without wanting to state the obvious... you're doing an aggregate function and ID is not in the group by clauseread about group by in books onlineEmSELECT ID, CalibScoreAVGQA,COUNT(CalibScoreAVGQA) AS Expr1FROM dbo.TechPhonesCalibScoreAVGQAgroup by ID, CalibScoreAVGQA |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-03-31 : 06:15:39
|
I think SQL Server is pretty obvious in its error message. All those columns which are not part of aggregate function like count(), sum(0 etc should be part of GROUP BY clause.SELECT ID, CalibScoreAVGQA,COUNT(CalibScoreAVGQA) AS Expr1FROM dbo.TechPhonesCalibScoreAVGQAGROUP BY ID, CalibScoreAVGQA Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-03-31 : 06:31:43
|
| Yes, I got that what if I want to get the average of the whole column CalibScoreAVGQA? With this formula, the average is computed per row. I want the whole average of a certain column. |
 |
|
|
pravin14u
Posting Yak Master
246 Posts |
Posted - 2008-03-31 : 06:32:54
|
| Select 'Average',Avg(CalibScoreAVGQA)from dbo.TechPhonesCalibScoreAVGQAORSelect Avg(CalibScoreAVGQA) as 'Average of CalibScoreAVGQA'from dbo.TechPhonesCalibScoreAVGQA--Remember this will not consider records with NULL value for CalibScoreAVGQAPrakash.PThe secret to creativity is knowing how to hide your sources! |
 |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-03-31 : 06:38:59
|
| Here's the results i've got:ID CalibScoreAVGQA Average of CalibScoreAVGQA1 0 02 1 1What I need is the average of CalibScoreAVGQA (1+0/2). |
 |
|
|
pravin14u
Posting Yak Master
246 Posts |
Posted - 2008-03-31 : 07:15:01
|
quote: Originally posted by cutiebo2t Here's the results i've got:ID CalibScoreAVGQA Average of CalibScoreAVGQA1 0 02 1 1What I need is the average of CalibScoreAVGQA (1+0/2).
When I said OR, i meant that you need execute any one of the above queries.Both the queries are doing the same thing and displaying the results in a different wayPrakash.PThe secret to creativity is knowing how to hide your sources! |
 |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-03-31 : 07:21:10
|
| Yes, how can I get the average of the values in column CalibScoreAVGQA? |
 |
|
|
pravin14u
Posting Yak Master
246 Posts |
Posted - 2008-03-31 : 07:54:25
|
| Select Avg(CalibScoreAVGQA) as 'Average of CalibScoreAVGQA'from dbo.TechPhonesCalibScoreAVGQAPrakash.PThe secret to creativity is knowing how to hide your sources! |
 |
|
|
|