Subject Re: [firebird-support] Advice with the following sql command
Author W O
If a column in a SELECT list is not an aggregate function then you need to write it in the GROUP BY clause.

Many people have your same problem when start using SQL.

Greetings.

Walter.



On Thu, Sep 25, 2014 at 9:38 AM, 'Andrew Gable' andrew.gable@... [firebird-support] <firebird-support@yahoogroups.com> wrote:
 

Hi all,

I need someone please to advice me of the following sql code

 

Select TRANS_DATE,TRANSTIME, POSNUMBER, TRANSNUMBER, Count(ITEM_QTY) as ItemsSold,

SUM(LINE_TOTAL) as LineTotal from accounthistory "

WHERE TRANS_DATE BETWEEN '" & StartDate & "' AND '" & EndDate AND AccountID='1001'

GROUP BY POSNUMBER, TRANSNUMBER Order By TRANS_DATE, TRANSTIME DESC;

 

When I run that within my application I get this error message

 

Run Time Error -2147467259 (80004005)


[ODBC Firebird Driver][Firebird] SQL Error
SQL error code =-104
Invalid expression in the select list (not contained in either an aggregate function or the GROUP BY clause)

 

Any advice is welcomed as this has me stumped as well as my SQL expert mate

 

Thanks

Andy