var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Query needed urgently :- fetching latest status of Employees
I have a table Employee with 3 columns.
emp_Id | begindate | Enddate
001 2013-01-01 2013-12-31
001 2014-01-01 2014-12-31
001 2015-01-01 null
002 2013-01-01 2013-12-31
002 2014-01-01 2014-12-31
002 2015-01-01 null
003 2013-01-01 2013-12-31
003 2014-01-01 2014-12-31
enddate gets updated after the end of every year. Employees are active when the enddate is not null against their ods. i.e. employee 001 and 002.
When the enddate is null, the employees do not exist in the company anymore. Inactive. i.e. 003.
I would like to fetch employeeId and their latest status.
emp_id | status
Thank you in advance
that is some odd logic. there are always many ways to get what you want with SQL
select employee, max(case when enddate is null then 'inactive' else 'active' end)
You can use a subselect to get the max,