Mohit Kala

Mohit Kala

  • 566
  • 2.1k
  • 136k

Need Help In Sql Filter Query

Jun 18 2018 1:05 AM
I Have 3 Dropdwon Branch,department,level And i Want to filter record according to these 3 parameters all parameters is nullable 
 
my query is
 
SELECT e.EmployeeID,e.LevelID,e.EmployeeCode,e.EmailID,e.MobileNo,e.BranchID,e.DepartmentID,e.EmployeeName,
b.BranchName,d.DepartmentName FROM EMPLOYEE e
LEFT OUTER JOIN Department d ON d.DepartmentID=e.DepartmentID
LEFT OUTER JOIN Branch b ON b.BranchID=e.BranchID
WHERE e.IsDeleted<>1 AND @BranchID IS Null or e.BranchID=@BranchID AND @DepartmentID IS NULL OR
e.DepartmentID=@DepartmentID AND @LevelID IS NULL OR e.LevelID=@LevelID
   
 
Pls Help Me 

Answers (4)