Subject | Re: [firebird-support] Help on this SQL statment |
---|---|
Author | Nagy Szilveszter |
Post date | 2013-06-15T16:56:48Z |
GROUP BY PRODUCTDESCRIPTION there is PRODUCTCODE missing here
if you use aggregate functions u have to add all fields to GROUP BY that are not used with aggregate functions
________________________________
From: Andrew gable <andrew.gable@...>
To: firebird-support@yahoogroups.com
Sent: Saturday, June 15, 2013 7:54 PM
Subject: [firebird-support] Help on this SQL statment
Hi everyone,
Can someone please advise me as to what is happing with this SQL Select
statement I am trying to use
SQLCommand = vbNullString
SQLCommand = SQLCommand & "SELECT "
SQLCommand = SQLCommand & "PRODUCTCODE,"
SQLCommand = SQLCommand & "PRODUCTDESCRIPTION,"
SQLCommand = SQLCommand & "SUM(PRODUCTQTY),"
SQLCommand = SQLCommand & "SUM(PRODUCTTOTAL) "
SQLCommand = SQLCommand & "From ProductHistory "
SQLCommand = SQLCommand & "WHERE PRODUCTDATE Between '" & StartDate & "'
AND '" & EndDate & "' "
SQLCommand = SQLCommand & "GROUP BY PRODUCTDESCRIPTION "
SQLCommand = SQLCommand & "ORDER BY PRODUCTQTY DESC "
SQLCommand = SQLCommand & "ROWS 1 TO 25"
I am getting the following error
-2147467259 - [ODBC Firebird Driver][Firebird]Dynamic SQL Error
SQL error code =-104
Invalid expression in the select list (not contained in either an aggregate
function or the GROUP BY clause)
If someone could explain that to me I would be most greatful.
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
if you use aggregate functions u have to add all fields to GROUP BY that are not used with aggregate functions
________________________________
From: Andrew gable <andrew.gable@...>
To: firebird-support@yahoogroups.com
Sent: Saturday, June 15, 2013 7:54 PM
Subject: [firebird-support] Help on this SQL statment
Hi everyone,
Can someone please advise me as to what is happing with this SQL Select
statement I am trying to use
SQLCommand = vbNullString
SQLCommand = SQLCommand & "SELECT "
SQLCommand = SQLCommand & "PRODUCTCODE,"
SQLCommand = SQLCommand & "PRODUCTDESCRIPTION,"
SQLCommand = SQLCommand & "SUM(PRODUCTQTY),"
SQLCommand = SQLCommand & "SUM(PRODUCTTOTAL) "
SQLCommand = SQLCommand & "From ProductHistory "
SQLCommand = SQLCommand & "WHERE PRODUCTDATE Between '" & StartDate & "'
AND '" & EndDate & "' "
SQLCommand = SQLCommand & "GROUP BY PRODUCTDESCRIPTION "
SQLCommand = SQLCommand & "ORDER BY PRODUCTQTY DESC "
SQLCommand = SQLCommand & "ROWS 1 TO 25"
I am getting the following error
-2147467259 - [ODBC Firebird Driver][Firebird]Dynamic SQL Error
SQL error code =-104
Invalid expression in the select list (not contained in either an aggregate
function or the GROUP BY clause)
If someone could explain that to me I would be most greatful.
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]