mysql - Difference between two dates that are on different rows and columns? -


my table schema looks this..

load_id | stoptype | departure_date | arrival_date 

there 2 stop types pk(pickup) or dl(delivery)

if stop type pk departure date exists , if stop type dl delivery date exists. each departure , delivery couple load id same. complicates me aren't in rows right next each other. query should use?

you try that:

select load_id, max(departure_date), max(arrival_date) table group load_id 

this query return every load both dates, next step calculate difference via datediff, like:

select load_id, datediff(max(arrival_date), max(departure_date)) diff table group load_id 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -