Wednesday, January 26, 2011

count distinct rows

with DateRowCount(col1,CountRows)
as
(
select col1,COUNT(col1)
over (partition by col1) from table1 as CountRows
)
select col1, CountRows
from DateRowCount
group by col1, CountRows
order by col1

No comments:

Post a Comment