-1

I have a Table from that want to get records on the bases of gender and score like if the score is more than 70 than male data will display else female data for this i want to use case statement. mysql query is

select Parent_Id,Emp_Id,Emp_Gender,Emp_Score from EVENT_DETAIL where 
Emp_Score = (case when Emp_Score > '70' then (select * from EVENT_DETAIL 
where Emp_Gender = 'Male') else (select * from EVENT_DETAIL where 
Emp_Gender = 'Female') end); 

but in this am getting error of operand should contain 1 column

Aishwarya
  • 433
  • 3
  • 10

1 Answers1

0

Is this what you wanted?

(select Parent_Id,Emp_Id,Emp_Gender,Emp_Score from EVENT_DETAIL where Emp_Score > 70 and Emp_Gender = 'Male')
union all
(select Parent_Id,Emp_Id,Emp_Gender,Emp_Score from EVENT_DETAIL where Emp_Score <= 70 and Emp_Gender = 'Female');
Vlam
  • 1,622
  • 1
  • 8
  • 17
  • the query you are telling is already i have tried but i want to do only with case statement – Prince Mahipal Feb 08 '18 at 06:18
  • new query i have made select * from EVENT_DETAIL where Emp_Score IN (case when Emp_Score >= '70' then (select group_concat('''',Emp_Score,'''') as Emp_Score from EVENT_DETAIL where Emp_Gender = 'Male') else (select group_concat('''',Emp_Score,'''') as Emp_Score from EVENT_DETAIL where Emp_Gender = 'Female') end); now am getting empty set. – Prince Mahipal Feb 08 '18 at 06:19