Home » SQL & PL/SQL » SQL & PL/SQL » maximum value of 3 columns as new column
maximum value of 3 columns as new column [message #362341] Mon, 01 December 2008 22:14 Go to next message
mrkcse
Messages: 62
Registered: November 2007
Location: Mumbai,India
Member
HI all,


Iam having simple table with three columns ,i need to get fourth new column which is greatest of the first three columns rowwise.
Re: maximum value of 3 columns as new column [message #362343 is a reply to message #362341] Mon, 01 December 2008 22:40 Go to previous messageGo to next message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member


Let me assume the columns are of numeric Data type.

Use Greatest and NVL(if needed) .

Smile
Rajuvan.
Re: maximum value of 3 columns as new column [message #362346 is a reply to message #362343] Mon, 01 December 2008 23:25 Go to previous messageGo to next message
mrkcse
Messages: 62
Registered: November 2007
Location: Mumbai,India
Member
thanks for the reply.I will try
Re: maximum value of 3 columns as new column [message #362354 is a reply to message #362341] Tue, 02 December 2008 00:45 Go to previous message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Why do you want to create such a redundant column? You then need to add a constraint to ensure its value is ALWAYS the correct one.
Keep your model in 3NF and among this under the rule "no column should depend on other column(s) but the primary key".

Regards
Michel
Previous Topic: Strange requirement!
Next Topic: Need help to write query and Help to write SQL (2 threads merged by bb)
Goto Forum:
  


Current Time: Sun Dec 04 04:51:23 CST 2016

Total time taken to generate the page: 0.27457 seconds