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
How do I run a sql script?
explain normalization concept? : Sql dba
1. is it possible to use the cursor atttibutes (%found ,% rowcount , %isopen , %notfound ) to our user defined cursor names ....... cursor cursor_name is select * from scott.emp if you use... cursor_name%found , %rowcount ,%isopen,%notfound...will it work... -------------------------- 2.what is the difference between the varray and index by table .. -------- 3. type type_name is table of number(8,3) index by binary_integer; identifier_name type_name; first , last , prior , next ,trim are the methods we can use it for the above type...simillary is there any way to apply for cursors... with thanks and regards..sarao...
What is the purpose of normalization?
What is a recursive join sql?
what is the difference between clustered and non clustered index in sql? : Sql dba
which tcp/ip port does sql server run on? : Sql dba
Why sql query is slow?
What is the purpose of primary key?
Is it important to partition hard disk?
Which join is like inner join?
what are the difference between clustered and a non-clustered index? : Sql dba
Can we join tables without foreign key?
Can there be 2 primary keys in a table?
Which is better join or subquery?