Wednesday, 19 October 2011

Use of Group by with Update Query



Update a set a.CDRCOunts = ISNULL(a.CDRCOunts,0) + b.CDRCount
from dbmonitor.dbo.T_SCFFIles(nolock) a Inner join (Select file_id,COUNT(*) as CDRCount from CDR_Aug11(nolock) group by file_id) b

on a.fileid = b.file_id

No comments:

Post a Comment