I have a table with the following columns:
GLLink int
Budget01 float
Budget02 float
Budget03 float
Budget04 float
Budget05 float
Budget06 float
Budget07 float
...
Budget57 float
Budget58 float
Budget59 float
Budget60 float
For each column, there is 8 rows because of my filter.
All of these columns has values.
I need to set each columns value to zero, however I have the understanding that I would need to pivot the data and then update afterwards?
I know you can just transpose
the results in Excel and then develop you query in Excel, however, I would like to know how to achieve this without using Excel.
After the transpose in Excel, my update query would look like this:
update Budgets set Budget01 = 0 where GLLink in (select AccountLink from Accounts where Master_Sub_Account like '3200>%')
update Budgets set Budget02 = 0 where GLLink in (select AccountLink from Accounts where Master_Sub_Account like '3200>%')
update Budgets set Budget03 = 0 where GLLink in (select AccountLink from Accounts where Master_Sub_Account like '3200>%')
update Budgets set Budget04 = 0 where GLLink in (select AccountLink from Accounts where Master_Sub_Account like '3200>%')
update Budgets set Budget05 = 0 where GLLink in (select AccountLink from Accounts where Master_Sub_Account like '3200>%')
update Budgets set Budget06 = 0 where GLLink in (select AccountLink from Accounts where Master_Sub_Account like '3200>%')
update Budgets set Budget07 = 0 where GLLink in (select AccountLink from Accounts where Master_Sub_Account like '3200>%')
...
update Budgets set Budget57 = 0 where GLLink in (select AccountLink from Accounts where Master_Sub_Account like '3200>%')
update Budgets set Budget58 = 0 where GLLink in (select AccountLink from Accounts where Master_Sub_Account like '3200>%')
update Budgets set Budget59 = 0 where GLLink in (select AccountLink from Accounts where Master_Sub_Account like '3200>%')
update Budgets set Budget60 = 0 where GLLink in (select AccountLink from Accounts where Master_Sub_Account like '3200>%')
How would I need to develop the same update query in SQL, without using Excel and taking all of the above in consideration?