根据SQL中两行的条件返回单个结果

时间:2018-08-23 14:52:46

标签: sql oracle

我正在处理项目管理数据库,并且我需要返回里程碑日期,但是如果计划了主要任务,则会对其进行标记。我的桌子看起来像这样:

+-------------+-----------+-----------+-------------+------------+
|    Task     | Milestone | End Date  |   Status    | Constraint |
+-------------+-----------+-----------+-------------+------------+
| Programming | No        | 8/11/2018 | Not Started | Calculated |
| Database    | Yes       | 8/22/2018 | In Process  | Calculated |
| Discovery   | Yes       | 8/1/2018  | In Process  | Calculated |
| Kick Off    | No        | 7/31/2018 | In Process  | Scheduled  |
+-------------+-----------+-----------+-------------+------------+

我需要结果像这样

+-----------+------------+
|   Phase   |  End Date  |
+-----------+------------+
| Database  | 8/22/2018  |
| Discovery | 7/31/2018* |
+-----------+------------+

里程碑任务和主要任务之间没有链接,因此我必须按名称将它们拉起。到目前为止,我遇到了一个无效的表达错误:

CASE
 WHEN {title}='Discovery : Discovery Complete' AND {status}='Completed'          
  THEN 'Done'
 WHEN ({title}='Discovery : Discovery Complete' AND {status}<>'Completed')
  AND ({title}='Discovery Meeting' AND {constrainttype} = 'Fixed Start')         
  THEN TO_CHAR({enddate}, 'MM/DD/YYYY') || '*'
 WHEN {title}='Discovery : Discovery Complete' AND {status}<>'Completed'         
  THEN TO_CHAR({enddate}, 'MM/DD/YYYY') 
 ELSE NULL 
END

谢谢!

0 个答案:

没有答案