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
Is it possible to read/write files to-and-from PL/SQL?
What is sql exception?
What are sql indexes?
What is a table partition?
What are % type and % rowtype?
tell me about various levels of constraint. : Sql dba
What is the difference between instead of trigger and after trigger?
Can you have more than one trigger on a table?
Explain the difference between sql and mysql.
How to start oracle sql developer?
Explain polymorphism in pl/sql.
Table 1: col1 Timestamp ---------------- 01-mar-2012 11:12:46 Table 2: col2 Timestamp -------------------- 01-mar-2012 11:12:10 01-mar-2012 11:11:23 Write a query to display a row with table2 col2 value less than tabl1 col1 value. Maximum timestamp value previous to table1 col1 value. Display a result as: Col1 col2 ----- ----- 01-mar-2012 11:12:46 01-mar-2012 11:12:10
What is pl sql in dbms?
How to call shell script from pl sql procedure?
what are rollup and cube in t-sql? : Transact sql