Skip to content
Advertisement

Datediff on 2 rows of a table with a condition

My data looks like the following

Now, I want to calculate the datediff between the closeddates for teams A, and B, if the max closeddate for team A is greater than max closeddate team B. If it is smaller or null I don’t want to see them. So, for example,I want to see only one record like this :

and for another tickets, display the info. For example, if the conditions aren’t met then:

Data sample for 2456:

I want to see the difference in days between 01/05/2019 for team A, and

10/08/2018 for team B.

Here is the query that I wrote, however, all I see is -1111111, any help please?:

Advertisement

Answer

Your sample query is quite complicated and has conditions not mentioned in the text. It doesn’t really help.

I want to calculate the datediff between the closeddates for teams A, and B, if the max closeddate for team A is greater than max closeddate team B. If it is smaller or null I don’t want to see them.

I think you want this per TicketId. You can do this using conditional aggregation:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement