I'm not sure what the best title of my question would be, but I'll explain my problem/question the best below:
I'm using the following query, where I filter on a workorder, and I gather all the history of it, which I would need to shown on my report:
select a.name, d.data, h.started, e.name, * from wshhistory h
join asset a
on a.uid = h.assetid
join wshfld d
on h.uid = d.wshhistid
join fielddefinition f
on d.flddefid = f.uid
join enumlookup e
on h.assetstatus = e.uid
where h.shdid = '43FEB092-D3B1-4008-9C44-A3A249987849' order by a.name, h.started asc
My result is fine, but...
What I would need is only 1 row (the last/top one) of each (unique) asset, and the other rows all as column, so that we only have 1 row for each asset. So that my report looks like:
In vb.net I would fix this with a for each loop going through all the assets, but with SQL my knowledge is limited, and I have no idea on how to solve this in a query.
Any idea?
Thank in advance!