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

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -