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
MAX(CASE WHEN ActivityRef = 1 THEN ScanDate END) AS ActivityRef1,
MAX(CASE WHEN ActivityRef = 3 THEN ScanDate END) AS ActivityRef3
GROUP BY PalletID
After the case when is ActivityRef instead of ActivityRef1.
If you have any question, please feel free to let me know.
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.