id name gender
1 Ram Female
2 Kumar Female
3 sathish Female
4 Santhya Male
5 Durga Male
6 Priya Male
This is my input...how to change Gender Male to Female &
Female to Male??? Write sql query for this question???
Answers were Sorted based on User's Feedback
Answer / yuvaevergreen
I am not sure whether decode will work in teradata 12.0 but case statement can be used.
update stud set gender =
case gender
when 'male' then 'female'
when 'female' then 'male'
end;
| Is This Answer Correct ? | 24 Yes | 1 No |
Answer / ankal
update stud set gender=
case gender when'male' then'female'
else 'male' end;
| Is This Answer Correct ? | 7 Yes | 0 No |
Answer / kumar amit ranjan
UPDATE stud SET gender ='Z' WHERE gender ='F';
UPDATE studmaster SET gender ='F' WHERE gender ='M';
UPDATE studmaster SET gender ='M' WHERE gender ='Z';
| Is This Answer Correct ? | 3 Yes | 2 No |
Answer / tdguy
update using case option is the best option for this query.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / srinu
update stud set gender= decode(gender,'M','F','F','M')
| Is This Answer Correct ? | 3 Yes | 3 No |
Answer / apurva kumar
UPDATE table
SET Gender = CASE
WHEN Gender = 'Male' THEN 'Female'
ELSE 'Male'
END
| Is This Answer Correct ? | 1 Yes | 1 No |
What is the multi-insert?
What is Difference b/w PI & PPI?how to implement PPI?
How do you eliminate duplicates?
how to load or extract the error table data ?
1. generally how many node system will be used by the client. 2. while running mload if the job is aborted/failed at any phase what we have to look after to run the job successfully? 3.i wanted to know how to write the fastload script for table creation as well as table loading in a single script?
What is a clique?
How a Referential integrity is handled in Teradata?
What is oltp?
What are default access rights in teradata? What explicit right can be given to a user?
what is identity columns in TD?
Difference between star and snowflake schemas?
i have column like below studentid studentname sub1 sub2 sub3 1 aaa 40 70 90 2 bbb 60 80 50 i want to execute every student highest mark in which subject my o/p like below studentid studentname sub3 sub2 1 aaa 90 2 bbb 80