SQL query aggregate function

william humphrey shoreagent at gmail.com
Fri Aug 15 11:53:54 CDT 2008


When doing this aggregate function:
select  d_cargo_pkgtype, d_cargo_description as theCargo,  (d_cargo_weight /
d_cargo_pieceCount), d_cargo_defaultcargodesc_ref, count(*) as theCount
from data_cargo join info_billoflading on cargo join info_clients on
consignees
where i_billoflading_clientShipper_ref = 8001
group by d_cargo_pkgtype, d_cargo_description, (d_cargo_weight /
d_cargo_pieceCount), d_cargo_defaultcargodesc_ref order by theCount desc,
theCargo asc


It doesn't work because the "group by" doesn't like the calculated (weight /
pieces). I also tried making that an alias and the "group by" refused to see
the alias even though the "order by" clause can see it.  I need the
calculated result in the "group by" aggregate because the calculated group
makes the rows have identical values.

Can you make a suggestion for me to try?

Thanks

Bill


More information about the Valentina mailing list