Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2008 > SQL Server 2008
|
SQL Server 2008 General discussion of SQL Server *2008* version only - not related to a specific book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2008 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 6th, 2012, 05:13 AM
Authorized User
 
Join Date: Dec 2009
Posts: 85
Thanks: 16
Thanked 0 Times in 0 Posts
Default not contained in aggregate function

Hi there

hoping someone can help:

I'm getting this error returned when I try and run this sql statement:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Column 'tbl_tenders.id' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.


This is the statement:

SELECT t.id, t.title, t.address, t.area, t.detail, t.maplink, t.imagename, t.imagename_m, t.imagename2, t.imagename2_m, t.startdate, t.enddate, t.dateadded, MAX(b.bid) AS 'maxbid', b.biddate FROM tbl_tenders t, tbl_bid b WHERE t.IsLive = 0 AND t.id = b.tenderid AND b.customerid = 1

I'm not sure what I need to do here, why do I need a group by clause - can anyone advise?


thanks

Adam
 
Old July 8th, 2012, 06:44 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

its insisting on this because you are asking this:

MAX(b.bid) AS ....

I'm sure if you removed this field it would not insist for GROUP BY and your query would run. Failing this you simply need to do what you have been asked:

GROUP BY t.id, t.title, t.address, t.area, t.detail, t.maplink, t.imagename, t.imagename_m......etc
__________________
Wind is your friend
Matt
 
Old July 9th, 2012, 09:11 AM
Authorized User
 
Join Date: Dec 2009
Posts: 85
Thanks: 16
Thanked 0 Times in 0 Posts
Default group by

Many thanks Mat41

I'll give that a bash.





Similar Threads
Thread Thread Starter Forum Replies Last Post
aggregate function polofson BOOK: Professional SQL Server 2005 Reporting Services ISBN: 0-7645-8497-9 0 August 14th, 2007 01:29 PM
Using AVG aggregate function with decimal elygp SQL Server 2000 2 May 7th, 2007 09:04 PM
Aggregate Function MAX, SUM Manu SQL Language 2 May 30th, 2006 04:40 AM
Aggregate Function Adamcg Access 3 December 5th, 2005 09:24 AM
Count aggregate function Robert_Hill BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 August 24th, 2004 01:12 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.