there are 2 variables called x and y ,x contains 1,2 and y
contains 3,4 we have to swap the values from x to y and y
to x with out using dummy variables and it can be done only
by using a single statement ? how?
Answer Posted / nanne saheb c
Assume that the sample table is as below
X Y
------------
1 3
2 4
Update sample set
X=decode(X,1,3,2,4),
Y=decode(Y,3,1,4,2);
(OR)
Update sample set
X = (case when 1 then 3
when 2 then 4
end),
Y = (case when 3 then 1
when 4 then 2
end);
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
What are basic techniques of indexing?
What is clustered index sql?
Do triggers have restrictions on the usage of large datatypes, such as long and long raw?
What is percent sign in sql?
What is lookup table in sql?
What is keys and its types?
How does postgresql compare to "nosql"?
Why do we use view in sql?
What is a call statement? Explain with an example.
What are database links used for?
What is data manipulation language?
What is a null value?
Can we change the table name in sql?
What is an index? What are the types of indexes? How many clustered indexes can be created on a table?
What are different methods to trace the pl/sql code?