Home » Other » Training & Certification » Query
Query [message #330810] Tue, 01 July 2008 06:57 Go to next message
Akash Nathile
Messages: 38
Registered: October 2006
Location: Pune
Member
Data into emp_test is as follow:

select *
from emp_test;

emp_id emp_no
1 10
2 25
3 -30
4 40
5 15
6 16
7 -40
8 30
9 -10
10 -25


If data into "emp_no" field is same irrespectively to positive and negative sign I want 1 in new field "Expected_Row" if not same then retrive 0.

Now i want data in this format

emp_id emp_no Expected_Row
1 10 1
2 25 1
3 -30 1
4 40 1
5 15 0
6 16 0
7 -40 1
8 30 1
9 -10 1
10 -25 1


Thanks in advance.

[Updated on: Tue, 01 July 2008 07:15]

Report message to a moderator

Re: Query [message #330819 is a reply to message #330810] Tue, 01 July 2008 07:20 Go to previous messageGo to next message
Frank
Messages: 7901
Registered: March 2000
Senior Member
We have a policy here at OraFAQ to not do other people's homework assignments.
We DO want to help though, but first you have to show that you made an effort yourself.
Show what you tried, what the result is and why it is not correct.

hint: if you get stuck use "where exists" or an outer join on the same table.

[Updated on: Tue, 01 July 2008 07:21]

Report message to a moderator

Re: Query [message #331080 is a reply to message #330810] Wed, 02 July 2008 05:02 Go to previous message
Michel Cadot
Messages: 68728
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Use DECODE function or CASE expression<

Please read OraFAQ Forum Guide, especially "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.
Also always post your Oracle version (4 decimals).

Regards
Michel
Previous Topic: career advise to join oracle financial
Next Topic: Trigger
Goto Forum:
  


Current Time: Fri Dec 27 22:31:46 CST 2024