sql - Mysql select unique value + first occurrence + last occurence -


i'm having trouble creating query returns following table containing transactions. table looks this:

id address_from address_to timestamp 

so want create list contains:

all unique addresses , first transaction , last.

i have no problem selecting unique addresses this:

select address_from address    transactions  union  select address_to address    transactions 

but how can add first timestamp address appeared in either address_from or address_to , last? hints in right direction highly appreciated.

is want?

select address, min(timestamp), max(timestamp) ((select address_from address, timestamp         transactions        )       union       (select address_to address, timestamp        transactions       )      ) group address; 

this has timestamps addresses, not ids. unclear looking for.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -