I have a question on this Cnt.
This query I make it as outer cursor query
SELECT DNum,LNum,Cd,count([EMployeeUI]) TotalEmployees FROM dbo.Temp WHERE EMployeeUI IS NOT NULLgroup by DNum,LNum,CdNow in the Insert into main table I have a case logic
( Now how I can refer Cnt form the outer cursor query?
case when (Cnt.TotalEmployees is not null or Cnt.TotalEmployees >0) then (T1.FRGN_AMT / Cnt.TotalEmployees) else 0 end,
See Luis' example. It does exactly this (without using a cursor).
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA