0

I have a scenario where the max function should work as follows in PostgreSQL:

select max(3,null) from table

should return 3

whereas,

select max(null) from table

should return null.

Suggestions are welcomed!

1
  • 1
    I've removed the tag spam and just left [postgresql], as that's what's in your title. Spamming tags doesn't help us help you and doesn't make your question more likely to get views from people who can help you, it's more likely to attract downvotes from people who are SMEs in a tagged technology that has nothing to do with the question you are asking. Commented Feb 9, 2022 at 9:51

1 Answer 1

3

max() is an aggregate that works across rows, not columns.

You are looking for greatest()

select greatest(3,null) from table
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.