• What about this?

    select a.*, ISNULL(b.result, 0)

    from [Table_A] as a

    OUTER APPLY ( SELECT *

    FROM (SELECT DeliveryDate, MIN(ID) as ID, SUM(Pass) as Pass, SUM(VM_Id) as VM_ID,

    CASE WHEN SUM(VM_ID) > 0 THEN CAST(ROUND((SUM(Pass) / CAST(SUM(VM_Id) AS DECIMAL(5, 2))) * 100.00 , 0 ) AS INT) ELSE 0 END AS Result

    FROM [Table_A]

    WHERE SummaryType > 0

    GROUP BY DeliveryDate) AS bb

    WHERE a.ID = bb.ID) b

    A bit lazy with the coding though, I'm sure there is a better way to do the conversions to decimals etc but this should get you what you want hopefully!

    ---------------------------------------------------------

    It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
    David Edwards - Media lens[/url]

    Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
    Howard Zinn