Returning a Max Result in a column

Steve Smith
Steve Smith Member
edited April 23 in Magic ETL

CASE
WHEN D's % of AOR = MAX(D's % of AOR) THEN 1
ELSE 0
END

Some how this is returning the total for the column. All values are returning a 1.

Tagged:

Comments

  • Try converting to a window function so that each row is compared to a single value instead of the aggregated value.

    CASE WHEN `D's % of AOR` = MAX(`D's % of AOR`) OVER () THEN 1
    ELSE 0
    END
    

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Used this exact code to return the max date, however, with this code all values are retuning 0.