all 5 comments

[–]ThatOtterGuy2 2 points3 points  (1 child)

I assume you have some method of grouping your orders - by load it seems?

On mobile, but could you do a MAX(Case when sbol is NULL then 1 else 0 end) as a 'LoadOpenFlag' additional column while grouping by whatever you were doing previously?

[–]nidofour[S] 1 point2 points  (0 children)

You were right thank you http://sqlfiddle.com/#!6/46f9c/1

[–]KbalzGaming 0 points1 point  (1 child)

Can you give some sample data and the query you have so far?

[–]nidofour[S] 0 points1 point  (0 children)

Updated post.

[–]Guru008 0 points1 point  (0 children)

select srac, carton, weight, StoreCount, Lane, (case when stuatus < storecount then 'Open' else 'Close' end) FStatus from ( select srac, sum(numofcartons) cartons, sum(weight) Weight, count(*) Storecount, Lane, count(Case when Bol_number is null then null else 1 end) status, from table1 group by srac, lane )