Consider a table with 8 rows 4 rows contains value 0 and 4
rows contains value 1.Now write a single update query to make
all 0's as 1 and all 1's as 0
Answers were Sorted based on User's Feedback
Answer / ajay sharma
UPDATE mytable set mycolumn = (mycolumn + 1)%2
| Is This Answer Correct ? | 21 Yes | 4 No |
Answer / vicky
Update test01 Set num =(case num when 1 then 0 when 0
then 1 else 3 end)
| Is This Answer Correct ? | 10 Yes | 2 No |
Answer / shaheem ck
UPDATE <tablename>
SET <columnname> = DECODE(<columnname>,0,1,
1,0,
<columnname>);
| Is This Answer Correct ? | 4 Yes | 3 No |
Answer / madhu sudhan g
Hiii Lets take a table Test contains one field No having 8
rows in that 4 rows are with 0's and 4 rows with 1's to update
Update Test
SET No=case when 1 then o
else 1
ENd
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / vernold
Update Table1 Set Column = case when Column = 1 then 0
when column = 0 then 1
| Is This Answer Correct ? | 5 Yes | 7 No |
Answer / krishna reddy l
update example set column1 = case when column1=0 then 1
when column1=1 then 0 end
| Is This Answer Correct ? | 0 Yes | 3 No |
Answer / vicky saini
Update (tablename) set (coulmn name)=1 where (coulmn name)
=0
| Is This Answer Correct ? | 1 Yes | 6 No |
how you can get the list of largest tables in a database? : Sql server administration
What is the maximum number of index per table?
How do you rebuild an identity column?
What is the command dbcc checkdb used for?
If we delete pack Spec what will be the status of pack Body ?
How many cores do I need for sql server 2016?
What is row by row processing ?
How to modify existing triggers using "alter trigger"?
Can you explain how long are locks retained within the repeatable_read and serializable isolation levels, during a read operation with row-level locking?
What are the restrictions that views have to follow?
What is the exact numeric data type in sql?
What are the differences between decimal and float in ms sql server?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)