Placing "where CustomerType is not null" inside the subquery gives me a higher result (count) than placing it outside, but I'm not sure why. Ideas?select s.IDfrom (select row_number() over (partition by a.ID order by a.DateUpdated desc) as [DateRank], a.ID, a.DateUpdated, a.Type, a.CustomerTypefrom db1.dbo.table1 awhere a.CustomerType is not null) swhere s.[DateRank] = 1
vs.select s.IDfrom (select row_number() over (partition by a.ID order by a.DateUpdated desc) as [DateRank], a.ID, a.DateUpdated, a.Type, a.CustomerTypefrom db1.dbo.table1 a) swhere s.[DateRank] = 1and s.CustomerType is not null