select ID,Name, (select ActionDate from 表结构和示例 where ID=t.ID and Action=1 order by ActionDate desc limit 1) as ActionDate1, (select ActionDate from 表结构和示例 where ID=t.ID and Action=2 order by ActionDate desc limit 1) as ActionDate2, (select ActionDate from 表结构和示例 where ID=t.ID and Action=3 order by ActionDate desc limit 1) as ActionDate3, (select Operater from 表结构和示例 where ID=t.ID and Action=1 order by ActionDate desc limit 1) as Operater1, (select Operater from 表结构和示例 where ID=t.ID and Action=2 order by ActionDate desc limit 1) as Operater2, (select Operater from 表结构和示例 where ID=t.ID and Action=3 order by ActionDate desc limit 1) as Operater3
from 表结构和示例 t group by ID
select ID, Name,max(if(Action=1,ActionDate,'')), max(if(Action=1,Operater,'')), .... from tt group by ID, Name
select ID,Name,
(select ActionDate from 表结构和示例 where ID=t.ID and Action=1 order by ActionDate desc limit 1) as ActionDate1,
(select ActionDate from 表结构和示例 where ID=t.ID and Action=2 order by ActionDate desc limit 1) as ActionDate2,
(select ActionDate from 表结构和示例 where ID=t.ID and Action=3 order by ActionDate desc limit 1) as ActionDate3,
(select Operater from 表结构和示例 where ID=t.ID and Action=1 order by ActionDate desc limit 1) as Operater1,
(select Operater from 表结构和示例 where ID=t.ID and Action=2 order by ActionDate desc limit 1) as Operater2,
(select Operater from 表结构和示例 where ID=t.ID and Action=3 order by ActionDate desc limit 1) as Operater3
from 表结构和示例 t
group by ID
max(if(Action=1,Operater,'')),
....
from tt group by ID, Name