Reputation: 23
I have written a query to display this data, the last column gives data by using this query.
TIMESTAMPDIFF(MINUTE,booking_activity.activity_time,booking.pick_up_time) AS ActualWaitingTime
Now, I have to only display the negative values, and all the positive values should become 0.
How should this query be edited?
Upvotes: 0
Views: 575
Reputation: 369
you can use the CASE function to make anything greater than or equal to zero as zero
or alternatively in your WHEN clause to only return values less than zero
Upvotes: 0
Reputation: 15140
Try:
CASE
WHEN TIMESTAMPDIFF(MINUTE,booking_activity.activity_time,booking.pick_up_time) < 0
THEN TIMESTAMPDIFF(MINUTE,booking_activity.activity_time,booking.pick_up_time)
ELSE 0
END AS ActualWaitingTime
Upvotes: 1