PostgresSQL get highest value with certain condition

PostgresSQL get highest value with certain condition

<strong>Sample Database Table called test</strong>

Sample Database Table called test

I am trying to get the row that has the highest priority within the last and same height

Here is what I have tried so far

I first tried getting the highest priority in the table and I successfully got the result by using the query below

SELECT * FROM test WHERE priority = (SELECT MAX(priority) FROM test)

Now, I thought this query would work but this throws an error message.

SELECT * FROM test WHERE priority = (SELECT MAX(priority) FROM test ORDER BY height DESC) 
ERROR: column "t2.height" must appear in the GROUP BY clause or be used in an aggregate function

Can anyone guide me how to solve this?

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Learn PostgreSQL, PgAdmin, SQL and JDBC [Combo!] | Simpliv

Learn PostgreSQL, PgAdmin, SQL and JDBC [Combo!]

What is CRUD? | CRUD Operations with SQL and PostgreSQL

What is CRUD? | CRUD Operations with SQL and PostgreSQL - In this course we will be using SQL and PostgreSQL to perform CRUD operations

How to write SQL queries in PostgreSQL

In this tutorial, you will learn how to write simple SQL queries in PostgreSQL.