select time_diff(t1.timestamp, t2.timestamp) from the_table t1, the_table t2 where t1.customer_id = t2.customer_id and ... other conditions ....