Sajid Hussain

Sajid Hussain

  • 1.2k
  • 514
  • 100k

how to get distinct values from two table in sql

Jun 12 2015 2:05 AM
I have two tables in sql db server,name as EmployeeDuty and EmployeeStatus where
multiple records of same employees are exist,i used following queries to get last record against each employee.
1.var Empdutyleft = _service.GetAllEmployeeDuty().OrderByDescending(x => x.EndDate)
.GroupBy(x => x.Employee_Id).Select(x => x.First()).Where(x => x.ToSector_Id == sectorId).ToList();
 2. var EmpStatus = _service.GetEmployeeStatusBySector_Id(sectorId).OrderByDescending(x => x.EndDate)
  .GroupBy(x => x.Employee_Id).Select(x => x.First()).ToList();
i want to get that employee that exist in EmployeeDuty but not exist in EmployeeStatus

Answers (1)