I"m on Mysql 5.6 so window functions aren't available...
I need to get data on a customerid
level, but since this is on a transactional table, I want just the latest record which is denoted by the highest value of recordid
(it's an autoincrement field). Think of the grain as this:
recordid | customerid | attribute1 | updatetime
I was thinking of doing this, but was wondering if there's a better way
select
mytable.customerid,
attribute1
from mytable
inner join (
select
max(recordid) as maxid,
customerid
from mytable) as maxed
on mytable.recordid = maxed.maxid