Title, I have also found the relevant solutions on the Internet, many of the answers are such an SQL statement:
Select Id,accountid,mark,max (createtime) as Latest from Accountmark as B group by AccountId
Use the Max function. But there seems to be something wrong with the data I've looked up, and the anti-white piece of data doesn't correspond to the Mark field and the Createtime field at all!
What's going on? Does using the Max function work in groups like this?
There is also a statement: Select *,count (AccountId) as Num from
(SELECT * from Accountmark ORDER BY createtime desc) ' Temp '
Group BY AccountId ORDER BY createtime Desc
That's the right data to be found.
However, I need to create a view where query clauses are not allowed in MySQL view. Ask the big God for a SQL statement that can be implemented without clauses, and can detect the correct data. Thank you!
Workaround :
SELECT * from Accountmark as B where not exists (select 1 from Accountmark where accountid= B.accountid
and B.createtime<createtime)
Original address: http://bbs.csdn.net/topics/390958705
Go MySQL to group data after the time to remove the most recent data