Home » SQL & PL/SQL » SQL & PL/SQL » How to write the query? (oracle9i,win xp)
How to write the query? [message #333525] Sat, 12 July 2008 03:18 Go to next message
sharathmpatil
Messages: 38
Registered: February 2008
Location: Bangalore
Member
Hi
How to write the query for the following?I have a table with two columns one is commission and the other one is salary.I have to compare two columns and say whether the salary is more or commission is more.

Thanks in advance
Re: How to write the query? [message #333527 is a reply to message #333525] Sat, 12 July 2008 03:28 Go to previous messageGo to next message
S.Rajaram
Messages: 1027
Registered: October 2006
Location: United Kingdom
Senior Member
Read the oracle reference manual and search for keywords like Case or Decode.

Regards

Raj
Re: How to write the query? [message #333617 is a reply to message #333527] Sun, 13 July 2008 11:53 Go to previous messageGo to next message
EL-SAYED
Messages: 17
Registered: July 2008
Junior Member


try this code


select salary,commission_pct,
case when salary>nvl(commission_pct,0) then salary
else commission_pct end

from employees
Re: How to write the query? [message #333618 is a reply to message #333525] Sun, 13 July 2008 11:58 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
http://www.orafaq.com/forum/t/88153/0/
Please read & follow Posting Guideline as stated above
Re: How to write the query? [message #333621 is a reply to message #333617] Sun, 13 July 2008 12:06 Go to previous message
Michel Cadot
Messages: 68718
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
@EL-SAYED

please read OraFAQ Forum Guide

"How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.

"Responding to Posts" section:
Quote:
When responding to questions, if it is obviously a student with a homework assignment or someone else just learning, especially in the homework and newbies forums, it is usual to provide hints or clues, perhaps links to relevant portions of the documentation, or a similar example, to point them in the right direction so that they will research and experiment on their own and learn, and not provide complete solutions to problems. In cases where someone has a real-life complex work problem, or at least it may seem complex to them, it may be best to provide a complete demo and explanation.


Regards
Michel

[Updated on: Sun, 13 July 2008 12:06]

Report message to a moderator

Previous Topic: CLOB & characterset
Next Topic: Getting Mutating error in Trigger
Goto Forum:
  


Current Time: Thu Dec 05 01:08:21 CST 2024