Dear all I have a table with the following columns , Now I have two three rows with Department
Employee Table
| Emp_ID | First_Name | Last_Name |
| 1 | NEW | OLD |
| 2 | FOG | HOP |
Employee Detail table
| Table_ID | Emp_ID | Department | Salary | Visit_Date |
| 1 | 1 | HR | 1200 | 5/5/2021 |
| 2 | 2 | HR | 1300 | 8-8-2022 |
| 3 | 3 | ICT | 1400 | 01-01-2022 |
Now I want to get the employee detail with name Department,salary,Visit_Date I want to get only HR department employee and from HR only one Row whose date is latest date like 8-8-2022
below is my current query.
var MyQuery=(from nn in db.EmployeeDetail
from vv in db.Employee
where vv.Emp_ID=nn.Emp_ID
order by vv.department
select new EmployeeDetail
{
visit_date=nn.Visit_Date,
Salary=nn.Salary).FirstOrDefault(),
}).ToList();
but it return two rows of HR i need one row with latest visit Date.
}
Vishal YelvePosted Aug 23, 2022, 8:27 AM
Hi Mark,
Please find your expected result
Mark TaborPosted Aug 23, 2022, 7:26 AM
Sachin SinghPosted Aug 15, 2022, 11:29 AM
Mark TaborPosted Aug 15, 2022, 11:24 AM
Vishal YelvePosted Aug 15, 2022, 9:55 AM
Try this
Sachin SinghPosted Aug 15, 2022, 9:47 AM