Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old March 27th, 2004, 04:06 AM
monicks monicks is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 21 monicks User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
what's wrong?

can anybody please tell me what's wrong with this SQL statement?

SELECT SUM(total) as TOTAL, dealer_id from sales_invoice WHERE dealer_id='4' AND MONTH(date_ordered)='01' AND YEAR(date_ordered)='2003';

i get this error:

MySQL said:


#1140 - Mixing of GROUP columns (MIN(),MAX(),COUNT()...) with no GROUP columns is illegal if there is no GROUP BY clause

Reply With Quote
  #2  
Old March 27th, 2004, 07:04 AM
nazly nazly is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Colombo,SriLanka
Posts: 1,325 nazly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 18 sec
Reputation Power: 3
Send a message via Yahoo to nazly
RE: what's wrong?

You have two options..

Since you know that dealer_id='4' take off the dealer_id field from SELECT..

SELECT SUM(total) as TOTAL from sales_invoice WHERE dealer_id='4' AND MONTH(date_ordered)='01' AND YEAR(date_ordered)='2003';

---

Or use GROUP BY clause, coz you can't mix group and non group columns..

SELECT SUM(total) as TOTAL, dealer_id from sales_invoice WHERE dealer_id='4' AND MONTH(date_ordered)='01' AND YEAR(date_ordered)='2003' GROUP BY dealer_id;


Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > what's wrong?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway