Hi everybody,
Need the help of a Teradata expert on how the SQL below can be optimized. It's currently consuming a lot of CPU resources and using a lot of spool space.
Can anybody help?
SELECT tb1.store_id
,tb1.upc_id
,'10/10/2006' (date, format 'mm/dd/yyyy')
,(SUM(tb1.base_qty) - MIN(tb1.base_qty) - MAX(tb1.base_qty)) / (COUNT(tb1.txn_dt) - 2)
,(SUM(tb1.base_amt) - MIN(tb1.base_amt) - MAX(tb1.base_amt)) / (COUNT(tb1.txn_dt) - 2)
FROM orca_db.txn_dtl tb1
GROUP BY 1,2,3
HAVING COUNT(tb1.txn_dt) >= 6;
Thanks
Rick