Hi, Is there any command as the "greatest" in MySQL that returns the maximum value in multiple columns?

Select * from ANIMALS

Place Amount1 Amount2 Amount3 Amount4
1 1 5 0 1
2 1 3 8 2
3 1 4 2 4

My expected return:

Place Max
1 5
2 8
3 4

asked 12 Jan '15, 10:07

LGregianin's gravatar image

LGregianin
27661320
accept rate: 40%

edited 12 Jan '15, 11:37

Comment Text Removed

Please take a look at the GREATER function. It does what you want for two inputs only, so you may need to combine several of those - something like GREATER(GREATER(a,b),GREATER(c,d)).

permanent link

answered 12 Jan '15, 10:55

Elmi%20Eflov's gravatar image

Elmi Eflov
8061114
accept rate: 36%

1

You may also have a look at the other FAQ:

How to use MAX() as a scalar function?

(12 Jan '15, 11:03) Volker Barth
Replies hidden

Thanks a lot.

(12 Jan '15, 12:04) LGregianin
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×7

question asked: 12 Jan '15, 10:07

question was seen: 1,307 times

last updated: 12 Jan '15, 12:04