sql - DISTINCT TOP 10 on a Single Column -


the following sql statement not working, , not sure how correct it:

select     a0.test test,     count(distinct top 10 a0.test_clmn) cc      dbo.testing a0 group      test 

if remove top 10 returns results, else

incorrect syntax near keyword 'top'.

is possible apply distinct , top 10 on single column ?

edit: top 10 have after select ?

here understand query: want number of distinct values of test_clmn each test, if there more 10 distinct values want 10 count result.

if that's true, can this:

select  test,          case when count(distinct test_clmn) > 10             10         else             count(distinct test_clmn)         end countdistinct dbo.testing group test 

however, wrote in comments question - query posted doesn't make sense, guess.


Comments