August 27, 2014

Teradata SQL Aggregate functions example

select
car_key,
sum(deprn_amt) sum_dep,
avg(accum_deprn_amt) avg_dep,
max(accum_deprn_amt) max_dep,
min(accum_deprn_amt) min_dep,
count(*) cnt
from fact_car
having sum_dep != max_dep and cnt >10 and cnt < 20 and max(nk_deprn_run_ts) > date '2014-06-01'
group by asset_key
order by max_dep desc

No comments:

Post a Comment