Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GROUP BY Problem

Status
Not open for further replies.

adwarak

Programmer
Apr 29, 2003
11
0
0
US
Hi,

I have a temporary table temp1 which has these records.

err sev descr freq
---- --- ----- ----
16001 1 Session Number was not passed 155
16001 1 Session Number was not passed 244
16001 1 Session Number was not passed 283

I want to calculate the average of the freq column for all the err ids in the table.
I 've used the this query.

select err, sev, descr,avg(freq)
from #temp1
group by err,sev,descr,freq
order by err

After I run this query I get this result set which is not what i want.

16001 1 Session Number was not passed 155
16001 1 Session Number was not passed 244
16001 1 Session Number was not passed 283

Please advise on how to calculate the average of the freq column.

Many thanks in advance.
 
don't put freq in the group by clause.

Try this:
Code:
select err, avg(freq)
from #temp1
group by err
order by err

and go from there

Posting code? Wrap it with code tags: [ignore]
Code:
[/ignore][code]CodeHere
[ignore][/code][/ignore].
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top