SQL server Update using JOIN -


i used command in sql server update table using maximum data in other table innerjoin

        update dbo.table2         set table2.lastgrantdate = max(table1.plannedprojstartdate)                  table1 inner join table2         on table2.serial = table1.fundingestablish 

but doesn't work

it workes when use without max()

any way solve ??

you need use subquery. here 1 way:

    update t2     set t2.lastgrantdate = t1.maxppsd     table2 t2 inner join          (select fundingestablish, max(plannedprojstartdate) maxppsd           table1           group fundingestablish          ) t1          on t2.serial = t1.fundingestablish; 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -