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 id
s. unclear looking for.
Comments
Post a Comment