sql - Find a where start and end date are not null over multiple rows -
to keep simple have 1 table. 1 column lotnumber, 1 start date , 1 finish date. when first entry lot number enter has start date. depending on how many shift takes finish lot can have server rows no date until completed , have finish date.
shift.........lot..........start..........end
1...................1............o.............null
2...................1.......... null......... null
3.................. 1.......... null.......... o
1.................. 2........... o........... null
i want pick out lot number has both start , end date though not on same row. possible.
select t1.lotnumber blendingcycletime t1 inner join blendingcycletime t2 on t1.lotnumber = t2.lotnumber t1.actualstartdaytime not null , t2.actualfinishdaytime null
i have landed on doesn't work well. ideas?
try this:
create table #tb (shift int,lot int,startd int, endd int) go insert #tb values(1,1,0,null), (2,1,null,null), (3,1,null,0), (1,2,0,null) select * #tb select lot #tb group lot having max(startd) not null , max(endd) not null
Comments
Post a Comment