1.In a table Gender is a column in that male and female are
the two data.In a single statement i have to modify all male
to female and all female to male vice versa.
2.In a single query i need the count of male data,count of
female and total count
Answers were Sorted based on User's Feedback
Answer / sagar shinde
--Query for 1
update EMPLOYEE
set GENDER = decode(GENDER,'M','F','M')
/
--Query for 2
select GENDER,count(*)
from EMPLOYEE
group by GENDER
| Is This Answer Correct ? | 10 Yes | 0 No |
Answer / anithaletchumi
1.In a table Gender is a column in that male and female are
the two data.In a single statement i have to modify all male
to female and all female to male vice versa.
ans->
update emp_table e set gender = (select case gender
when 'F' then 'M' else 'F' end from emp_table f where
e.empid = f.empid and e.gender=f.gender);
-- empid is the primary key.
2.In a single query i need the count of male data,count of
female and total count
ans 1->
select ( select count(empid) from emp_table where
gender='m' or gender='M') as count_male, ( select count
(empid) from emp11 where gender='f' or gender='F') AS
count_female,( select count(empid) from emp_table) as
tot_count from dual;
ans 2->
select sum(decode(gender,'F',1,'f',1)) as count_female,sum
(decode(gender,'M',1,'m',1)) as count_male,count(*) as
tot_count from emp_table;
| Is This Answer Correct ? | 9 Yes | 3 No |
Answer / kd
2.
select gender, count(*)
from employee
group by gender
union
select 'total' as gender, count(*)
from employee
| Is This Answer Correct ? | 3 Yes | 0 No |
Explain the difference between $ORACLE_HOME and $ORACLE_BASE.
Name a tablespace automatically created when you create a database.
How to find locks exists in a table or not?
What is the use of lockboxes? Steps for lock box : oracle accounts receivable
HOW TO SPOT AHIERARCHY?
8. Supporting AP, AR and GL?
Is there any link between pr form(purchse requisition)and po form(purchase order)
In my table i'm having the duplicate records with sequence number and my requirement is when in new record is coming i want to delete existing old record(onlyone i.e maintaing the partial duplicate date )and add new record
What command would you use to encrypt a PL/SQL application?
how to replace not in with not exist?
pl help me, i want oracle HRMS training institute address,in chennai
What is chargeback invoice? How do we create it? : oracle accounts receivable