sql query to check status change of an item

  • I have a table dbo.tblPresentationStatus (sql script attached - table script.txt)

    I have to select rows where the status change is wrong. (not as per the correct flow as shown in attached image status_Flow.jpg)

    From 'Review' the status for a specific presentation ID can change to either 'Approve' or 'Presentation' or 'Close'

    From 'Approve' the status for a specific presentation ID can change to either  'Presentation' or 'Close'

    From 'Presentation' the status for a specific presentation ID can change to only  'Close'

    I want to write query to return Presentations with wrong status flow. So expected output as per records given in script attached should be :

    PrID |  Status1     |  Status2                  |  Status3       | Status 4

    103   | REVIEW  | PRESENTATION | APPROVE  |CLOSE

    101    | APPROVE | REVIEW               |      NULL     | NULL

    Attachments:
    You must be logged in to view attached files.
  • Why are you re-posting the same q?

    https://www.sqlservercentral.com/forums/topic/sql-query-to-check-the-status-change-for-an-item#post-4492292

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • The expected output is different in this case thats why.

    Table structure is also different. Hence posted as a new question.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply