sql server - SQL Query : Update from a select result -


here's sql query

update dbo.td_total_accounts set total_accounts = total  select annee, mois,[group], (  select sum(accounts_number)  olap.td_all_accounts  eomonth(cast( cast(mois nvarchar(2))+ '/' + '01'  + '/' + cast(annee nvarchar(4)) datetime)) <= eomonth(cast( cast(t2.mois nvarchar(2))+ '/' + '01'  + '/' + cast(t2.annee nvarchar(4)) datetime)) , [group] = t2.[group] ) total  olap.td_all_accounts t2 

the "total" column not recognized. can't manage name table resulting select t3 , use in set "total_accounts = t3.total"

thank in advance.

something should trick (change idcolumn row identifier), though urge take lad2025 comment consideration.

update t  set total_accounts = total  dbo.td_total_accounts t  inner join ( select idcolumn, annee, mois,[group], (  select sum(accounts_number)  olap.td_all_accounts  eomonth(cast( cast(mois nvarchar(2))+ '/' + '01'  + '/' + cast(annee nvarchar(4)) datetime)) <= eomonth(cast( cast(t2.mois nvarchar(2))+ '/' + '01'  + '/' + cast(t2.annee nvarchar(4)) datetime)) , [group] = t2.[group] ) total  olap.td_all_accounts t2 ) t3 on(t.idcolumn = t3.idcolumn) 

Comments

Popular posts from this blog

How to check data type in C++? -

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

sql server - SQL Query returns one result, does not return 0 or NULL result -