I have an employee table with fields EmpId , EmpName , DeptID , Salary , EditedOn, EditedBy and Address .It has following entries:
EmpId EmpName DeptID Salary EditedBy EditedOn Address
1 Sonia 2 25000 1 2015-02-10 NULL
2 Rahul 1 15000 1 2015-01-10 NULL
3 Pooja 3 12000 1 2015-04-05 NULL
5 Tanya 7 32000 1 2015-04-10 NULL
6 Raj 8 27000 1 2015-04-03 NULL
16 NULL 1 NULL NULL 2015-04-15 NULL
17 NULL 1 NULL NULL 2015-04-15 NULL
18 NULL 1 NULL NULL 2015-04-15 NULL
19 Roshni NULL NULL NULL NULL Vasco
27 gh NULL NULL NULL NULL kk
28 Priyanka 7000 NULL NULL Porvorim
29 Ramesh NULL NULL NULL NULL Vasco
I want to create a strored procedure proc_GetEmployeeOnSalaryrange and specify foll conditions :
if salary is between ( 0-10000)
Select EmpName, Salary , 'Range A'
Else if salary is between ( 10001-20000)
Select EmpName, Salary , 'Range B' and third condition is :
if salary is above 20000
Select EmpName, Salary , 'Range C'
and Range A , Range B and Range C should be hard coded . I dont know the if else syntax to be used. so please help .