|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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; |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > what's wrong? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|