View Full Version : Why it doesn't work?HELP!!


hipoagu
09-14-2005, 10:27 AM
Hi all,
I get this error "You tried to execute a query that does not include the specified expression 'SITENAME' as part of an aggregate function."


The query is:

SELECT o1.name AS SITENAME, o1.vertical_loc/10000000 AS LAT, o1.horizontal_loc/10000000 AS LON, c.CELLGLID AS CELLID, 'traffic_total' AS Expr1, sum((MEBUSTCH_HR+MEBUSTCH_FR)*period_duration)/sum(period_duration) AS Traffic, 'traffic_hr' AS Expr2, sum(MEBUSTCH_HR*period_duration)/sum(period_duration) AS Traffic_HR
FROM objects AS o1, objects AS o2, c_bts AS c, p_generic_cell AS p
WHERE c.int_id = o2.int_id and
o2.parent_int_id = o1.int_id and
p.bts_int_id = o2.int_id
GROUP BY SITENAME, LAT, LON, CELLID, Expr1, Expr2;

I know the problem is with the group by clause. In MySQL it just works using "group by p.bts_int_id. I learnt in access i have to include all non-aggregated fields in the group by clause, and that's what I've done!! WHY!!Please help me!!!

FoFa
09-14-2005, 10:37 AM
You have to use the original column name, not the alias, so use o1.name instead of SITENAME in the group by clause

hipoagu
09-14-2005, 04:27 PM
I'll check it...how stupid is MS Access!! I'd always prefer traditional SQL queries!!
Thanks a lot!!!I'll tell u later...

Bye!

hipoagu
09-15-2005, 02:20 AM
:d :d :d :d :d