我有一个表,在多个阶段列出项目和项目的状态。例如,一根管子经过切割、焊接、油漆。该表的设置方式,它列出了三次管道和柱下阶段,它将分别进行切割,焊接和油漆。
我想将表与本专栏中的表进行比较,看看这三个阶段之间是否存在任何不一致之处。
因此,如果一个管道仍处于切割阶段,它将显示特定的排,但如果管道处于焊接阶段,它将显示特定的排。
目前的数据如下:
Unique ID Job # Stage Due Date Status
120473 Job 12 Cutting 1/17/17 Not Complete
120473 Job 12 Welding 1/18/17 Not Complete
120473 Job 12 Painting 1/18/17 Not Complete
120475 Job 17 Cutting 1/26/17 Complete
120475 Job 17 Welding 1/27/17 Not Complete
120475 Job 17 Painting 1/28/17 Not Complete预期产出将是:
Unique ID Job # Stage Due Date
120473 Job 12 Cutting 1/17/17
120475 Job 17 Welding 1/27/17独特的ID 120475是完成在切割,所以这是为什么它将显示焊接代替。
发布于 2017-01-27 20:29:38
显然,今天是星期五,因为我想得太多了。
以下方法解决了我的问题:
select a.jobdescription, a.category, a.sequence, a.lotnumber, a.duedate, a.dpm, a.ps, a.stage, a.completed
from qiw_powerbi a
where (a.stage = "approved by client" and a.completed = "not complete") or (a.stage = "released to shop" and a.completed = "not complete")
group by a.catkey
order by a.categoryhttps://stackoverflow.com/questions/41901936
复制相似问题