Current location: Hot Scripts Forums » Programming Languages » ASP » More Difficult Select Statement for Newbie


More Difficult Select Statement for Newbie

Reply
  #1 (permalink)  
Old 06-30-03, 10:52 PM
bytwo bytwo is offline
New Member
 
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question More Difficult Select Statement for Newbie

as soon as I add the "Avg" function I get the error message below. If I remove the AVG I get just the first value from the first row. I'm trying
to retrieve the Top 3 records then average col1. Any help please?


SELECT DISTINCT TOP 3 Avg(col1) AS some_name, col2 FROM some_table WHERE col2 = '" & some_var & "' ORDER BY col2"


Microsoft JET Database Engine error '80040e21'

You tried to execute a query that does not include the specified expression 'userid' as part of an aggregate function.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-01-03, 12:14 AM
Shane Shane is offline
Coding Addict
 
Join Date: Jun 2003
Location: Maryland, US
Posts: 268
Thanks: 0
Thanked 0 Times in 0 Posts
add the Group By col1 to the end of your query.
__________________
Shane Bauer
Microsoft Certified Professional (MCP) - ASP.NET
ASP/ASP.net, C#, VB/VB.NET, PHP, Perl, SQL
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-01-03, 05:46 AM
bytwo bytwo is offline
New Member
 
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
What is that saying??? Keep it simple stupid.. Thank you very much. It worked. I must have been up to late.

Thanks again!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
If then statement acting up! geneane ASP 1 09-30-03 05:32 PM
Insert...select andreasberglind PHP 5 08-21-03 06:07 PM


All times are GMT -5. The time now is 09:00 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.