• Yes, there's a simpler way to do it which is faster, too. It's on the articles I showed you and I'm guessing it can be at least 3 times faster in execution and won't need you to create additional objects. The articles also show how to make this dynamic.

    SELECT MAX(CASE WHEN LocationName = 'Alston' THEN Activecases END) Alston_ActiveCases
       ,MAX(CASE WHEN LocationName = 'Keswick' THEN Activecases END) Keswick_ActiveCases
       ,MAX(CASE WHEN LocationName = 'Penrith' THEN Activecases END) Penrith_ActiveCases
       ,MAX(CASE WHEN LocationName = 'Alston' THEN LastSeen END) Alston_LastSeen
       ,MAX(CASE WHEN LocationName = 'Keswick' THEN LastSeen END) Keswick_LastSeen
       ,MAX(CASE WHEN LocationName = 'Penrith' THEN LastSeen END) Penrith_LastSeen
       ,MAX(CASE WHEN LocationName = 'Alston' THEN Refresh_date END) Alston_Refresh_date
       ,MAX(CASE WHEN LocationName = 'Keswick' THEN Refresh_date END) Keswick_Refresh_date
       ,MAX(CASE WHEN LocationName = 'Penrith' THEN Refresh_date END) Penrith_Refresh_date
    FROM test

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2