Hi @Testsubjec ,
Welcome to the microsoft TSQL Q&A forum!
The method provided by Erland is very clever, you can refer to it. However, there is a small mistake in his code:
CREATE VIEW Scanview AS
SELECT PalletID,
MAX(CASE WHEN ActivityRef = 1 THEN ScanDate END) AS ActivityRef1,
MAX(CASE WHEN ActivityRef = 3 THEN ScanDate END) AS ActivityRef3
FROM Scantable
GROUP BY PalletID
After the case when is ActivityRef instead of ActivityRef1.
If you have any question, please feel free to let me know.
Regards
Echo
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.