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".

  • It's not the same. The expected output is different in this case thats why.

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

    • This reply was modified 14 hours, 37 minutes ago by  SQL Bee.
  • SQL Bee wrote:

    It's not the same. The expected output is different in this case thats why. Table structure is also different. Hence posted as a new question.

    Can you at least prove that you have attempted to solve this question, using one or more of the techniques provided previously? It does seem very similar to what has been asked before.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • This was removed by the editor as SPAM

Viewing 5 posts - 1 through 4 (of 4 total)

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