Home » SQL & PL/SQL » SQL & PL/SQL » sql query
sql query [message #198033] Fri, 13 October 2006 22:53 Go to next message
ashish_pass1
Messages: 114
Registered: August 2006
Location: delhi
Senior Member
Hi All,

I need an o/p below here,
I got an o/p from table emp,some employees are entered the eno in the sal column and sal in the eno column..so,I want to correct this problem eno comes into eno and sal comes into sal column.
eno sal
1 10000
2 20000
30000 3
5 50000
60000 7
7000 8
40000 1
3 50000

but,I want an o/p for like this (for ex empno should be empno, sal should be sal,no interchange values)
eno sal
1 10000
2 20000
3 30000
5 50000
7 60000
8 7000
1 40000
3 50000


Please help me out from this probelm..
but please do it in sql not by pl/sql.
thanxx

Re: sql query [message #198043 is a reply to message #198033] Sat, 14 October 2006 01:44 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
And exactly how should we know when a number is a salary and when it is an empno?
There is no (definite) way of telling! Emp 2000 could get a sal of 10!
Re: sql query [message #198056 is a reply to message #198043] Sat, 14 October 2006 03:11 Go to previous messageGo to next message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
A quick and very dirty solution might be this (you can only pray http://www.orafaq.com/forum/fa/1605/0/ that such a WHERE condition is always true, and that not one employee looks like the one in Frank's example):
UPDATE employees SET
  eno = sal,
  sal = eno
  WHERE eno > sal;
Re: sql query [message #198072 is a reply to message #198056] Sat, 14 October 2006 06:11 Go to previous messageGo to next message
amul
Messages: 252
Registered: April 2001
Location: Chennai
Senior Member
ha ha i should appreciate your presence of mind...
Re: sql query [message #198110 is a reply to message #198072] Sun, 15 October 2006 00:52 Go to previous messageGo to next message
ashish_pass1
Messages: 114
Registered: August 2006
Location: delhi
Senior Member
hello littlefoot,
ur r wrong.
even i m confused too much because no body should kn weather emp.no is or salary is emp.no.
may be emp.no greater than salary or salary would be greater than emp.no.
its too dificult to solve the prblem??
Re: sql query [message #198142 is a reply to message #198110] Sun, 15 October 2006 15:26 Go to previous message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Well, not all problems have a solution. If it is impossible for you to explain what you currently have and rules which should be applied to this data in order to fix the situation, I'd say yes: it is difficult to solve the problem.

By the way, perhaps you should purchase a new keyboard. Many letters are missing while you type.
Previous Topic: Trigger Mutating issue
Next Topic: multiple NOT LIKE clause's
Goto Forum:
  


Current Time: Fri Dec 02 16:43:51 CST 2016

Total time taken to generate the page: 0.42778 seconds