Friday, January 1, 2021

MYSQL Case function

 

 

mysql case funcation

I have one table Student .So i want to fetch data according to percentage 

and give remark according to position .

set @no=0 ;
select
@no:=@no+1 as S_No
,name,percentage,
 CASE  WHEN  percentage >= 90 Then  'excellent'
 WHEN percentage >=60  then 'first'
 WHEN percentage >=59  then 'second'
 When percentage >=35  then 'third'
 else 'Fail' end as Remark
 from student



No comments:

Post a Comment

How to Find the Third highest salary in mysql

  set @b:=0; set @b1:=3;   # #select distinct salary,@b:=@b+1 as Row_no from emp select  * from emp where salary=( select salary from ( sele...