1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] Subtracting Rows Based on status in another Column in SQL [closed]

Discussão em 'Outras Linguagens' iniciado por Stack, Setembro 1, 2021.

  1. Stack

    Stack Membro Participativo

    I have a table that has a ticket_id, status and time stamp for the that status change. In my calculation i need to remove any time the ticket was in monitoring state. So essentially i need to calculate the time when the ticket goes into monitoring and then comes out of. A ticket status can change multiple times. See the data in below (subtracting 13:40 from 13:46). I need to get the column 'Adjustment needed in mins'.

    The expected result for this ticket example will be the column adjustment needed or a total of 5330 mins Any help would be appreciated

    Entry ID​
    Time Stamp​
    Status​
    Adjustment needed
    ABC​
    8/20/2021 13:46​
    Changed to: Working​
    6.3
    ABC​
    8/20/2021 13:40​
    Changed to: Monitoring​
    null
    ABC​
    8/20/2021 13:40​
    Changed to: Working​
    5324
    ABC​
    8/16/2021 20:57​
    Changed to: Monitoring​
    null
    ABC​
    8/16/2021 20:56​
    Changed to: Working​
    null
    ABC​
    8/16/2021 12:40​
    Changed to: Working​
    null
    ABC​
    8/16/2021 09:40​
    Changed to: Working​
    null​

    Continue reading...

Compartilhe esta Página