View Single Post
  #4 (permalink)  
Old 01-23-2007, 04:00 AM
Dimitar
 
Posts: n/a
Default ANY answer. Re: How to perform aggregation (sum) on a computed column?

Not answering the general question, merely a solution to your concrete example:
[sql]
select age*10 as xyz,t.* from my_table join (select sum(age) * 10 from my_table) t [/sql]
Notes:
1) The sum is computed just once and returned as a table of cardinality 1. The table is then joined with my_table. The whole statement requires two full table scans on my-table.
2) (A x 10) + (B x 10) = (A + B) x 10
Reply With Quote