select aid
, (select top 1 field1 from tb1 as b where a.aid=b.aid and field1<>'')
, (select top 1 field2 from tb1 as b where a.aid=b.aid and field2<>'')
, .....
from tb1 as a
group by aid
, (select top 1 field1 from tb1 as b where a.aid=b.aid and field1<>'')
, (select top 1 field2 from tb1 as b where a.aid=b.aid and field2<>'')
, .....
from tb1 as a
group by aid
, (select top 1 field1 from tb1 as b where a.aid=b.aid and field1<>'' order by id desc)
, (select top 1 field2 from tb1 as b where a.aid=b.aid and field2<>'' order by id desc)
)
, .....
from tb1 as a
group by aid
在MYSQL使用。