• Not sure from just this little bit, but a place to start is that it will never get to F if the test for P comes up true. Case statements stop as soon as they find a true condition.

    Also, why have the 1=1 in your Where clause?

    I'd most likely rewrite it as:

    WHERE

    (FPCH.ProcessedDateKey >= @Beg_Date AND FPCH.ProcessedDateKey <= @End_Date and 'P' = @DateSolution

    or

    AR.RunCycleDate>= @pBeg_Date AND AR.RunCycleDate<= @pEnd_Date and 'F' = @DateSolution)

    AND FPCH.InventoryStatusCode in (97,98)

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon