Discussion:
Odd SQL error
M. A. Sridhar
2006-07-17 17:20:35 UTC
Permalink
Hello,

Here is a query that produces a strange error:

select Address.city as atr_0, count(Address.line_1) as atr_1 from Address,Product where Product.address = Address.address_id and Product.inactive = '0' and Product.orgName = 2 group by Address.city order by 1,2

The error is:
'count' can only be used as an aggregate function.
But if I remove the '2' in the order by clause, the problem goes away. This means that Mckoi cannot order by aggregate functions, it seems. I'm rather surprised. Any comments? Fixes/changes?

Thanks in advance.
M. A. Sridhar
m_a_sridhar at yahoo dot com
Andrzej Miazga
2006-07-18 07:59:55 UTC
Permalink
Hello,

When you replace "order by 1, 2" by "order by 1, str_1", everything works OK.

Greetings,
Andrzej Miazga
----- Original Message -----
From: M. A. Sridhar
To: Mckoi mailing list
Sent: Monday, July 17, 2006 7:20 PM
Subject: *****SPAM***** Odd SQL error


Hello,

Here is a query that produces a strange error:

select Address.city as atr_0, count(Address.line_1) as atr_1 from Address,Product where Product.address = Address.address_id and Product.inactive = '0' and Product.orgName = 2 group by Address.city order by 1,2

The error is:
'count' can only be used as an aggregate function.But if I remove the '2' in the order by clause, the problem goes away. This means that Mckoi cannot order by aggregate functions, it seems. I'm rather surprised. Any comments? Fixes/changes?

Thanks in advance.
M. A. Sridhar
m_a_sridhar at yahoo dot com

Loading...