-
How to select the maximum value in a record among columns?
Hi,
I have a table with columns e.g. columnA (default to 1), columnB (default to 2), columnC (default to 3), columnD (default to 4), and another column named HIGHEST_VALUE. Column A, B, C or D is nullable column.
What is the best way to obtain the maximum value among columnA to D and populate this maximum value in HIGHEST_VALUE column. I understand MAX( ) function can be used but it is more for getting maximum value among records, not within one single record.
Any suggestions or comments would be greatly appreciated.
Thanks in advance!
-
select greatest(a, b, c, d) from your_table;
-
Thank you for the information!
-
Why would you want to store (and maintain) the highest value, when it can simply be calculated dynamically?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|