greatest() function returns undefined property
I think you want to use get_var(), not get_row() – looking at the documentation, MySQL’s GREATEST just returns a single value. $results will then just be the value of the greatest (be it up or down). If you want the greatest up and the greatest down, use; $wpdb->get_row(“SELECT GREATEST(up) AS ‘up’, GREATEST(down) AS ‘down’ …”)