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

c - Calling a function within a loop -

vb.net - Unbound DataGridView add row with checkbox error -

How i fill combobox items in Radgridview manually using in vb.net -