Sql 查询以使用列并区分结果集中的日期
我需要使用特定结果集中的列并区分日期。 我有一个表Employees,其中包含员工姓名、状态、加入日期、状态更改日期。 我的桌子在下面Sql 查询以使用列并区分结果集中的日期,sql,oracle,grouping,Sql,Oracle,Grouping,我需要使用特定结果集中的列并区分日期。 我有一个表Employees,其中包含员工姓名、状态、加入日期、状态更改日期。 我的桌子在下面 Employee_Name Status Date_of_Status Date_of_Promotion ----------------------------------------------------------- Prasanth Active 01/10/2007 NULL Kiran
Employee_Name Status Date_of_Status Date_of_Promotion
-----------------------------------------------------------
Prasanth Active 01/10/2007 NULL
Kiran Promoted NULL 01/03/2012
Ravi Promoted NULL 04/05/2012
最后,我需要得到的结果如下
Employee_Name Promoted Active
----------------------------------
Prasanth NULL 01/10/2007
Kiran 01/03/2012 NULL
Ravi 04/05/2012 NULL
这在甲骨文中可能吗?
如果是这样,您能告诉我怎么做吗?我们可以使用这个用例
Select Employee_Name ,
Case when Status = 'Promoted'
then Date_of_Promotion else NULL end as Promoted,
Case when Status ='Active' then
then Date_of_Status else NULL end as Active
From
EmployeeTable