Difference between Qualify and Having

pri picture pri · Oct 27, 2015 · Viewed 11.2k times · Source

Can someone please explain me, what is the difference between qualify...over...partition by and group by...having in Teradata?
I would also like to know if there are any differences in their performances.

Answer

dnoeth picture dnoeth · Oct 27, 2015

QUALIFY is a proprietary extension to filter the result of a Windowed Aggregate Function.

A query is logically processed in a specific order:

  1. FROM: create the basic result set
  2. WHERE: remove rows from the previous result set
  3. GROUP BY: apply aggregate functions on the previous result set
  4. HAVING: remove rows from the previous result set
  5. OVER: apply windowed aggregate functions on the previous result set
  6. QUALIFY: remove rows from the previous result set