Ordered Analytics function in Select and in Where with conflicting order - which is resolved 1st

Database
The Teradata Database channel includes discussions around advanced Teradata features such as high-performance parallel database technology, the optimizer, mixed workload management solutions, and other related technologies.

Ordered Analytics function in Select and in Where with conflicting order - which is resolved 1st

I am trying to decipher some code that loosely has this form

 

Select ID

        , max(<Date>) over (partition by ID, f2, f3 order by date rows between 1 following and 1 following)

        ,...

from tablea 

 

where 

 

qualify  row_number() over  (partition by ID, f3, f2, date order by f5, f6, f7) =1 

 

my theory is that the where clause is resolved leaving me with 1 row per ID and the select to work with; is that correct? 


Accepted Solutions
Junior Contributor

Re: Ordered Analytics function in Select and in Where with conflicting order - which is resolved 1st

WHERE <> QUALIFY.

The order of execution is as follows:
FROM - WHERE - Aggregate/GROUP BY - HAVING - OLAP - QUALIFY - SAMPLE - ORDER BY
1 ACCEPTED SOLUTION
2 REPLIES
Junior Supporter

Re: Ordered Analytics function in Select and in Where with conflicting order - which is resolved 1st

Hi.

 

First OLAP, then QUALIFY.

 

HTH.

 

Cheers.

 

Carlos.

Junior Contributor

Re: Ordered Analytics function in Select and in Where with conflicting order - which is resolved 1st

WHERE <> QUALIFY.

The order of execution is as follows:
FROM - WHERE - Aggregate/GROUP BY - HAVING - OLAP - QUALIFY - SAMPLE - ORDER BY