your current condition doesnt make any sense(ATT.A1 = 'A' AND ATT.A1 is null)how can same column have a value and be NULL at same time. It will always return nothingi think what you want is something likeSELECT SUM(CASE WHEN Val = 'A' THEN 1 ELSE 0 END) AS AS [Total Absenecs]FROM(SELECT ATT.*FROM ATT INNER JOIN STU ON ATT.SC = STU.SC AND ATT.SN = STU.SN WHERE STU.ID = 4090368)tUNPIVOT (Val FOR Cat IN ([A1],[A2],[A3],[A4],[A5],[A6]))u
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs