SQL Server - Count the number of times the contents of a specified field repeat in a table -


what's best way 'select' 'distinct' list of field table / view (with 'where' criteria) , alongside count number of times that field content repeats in table / view?

in other words, have initial view looks bit this:

initial table/view

i'd single sql query filter (select...where...) considering records [order complete] = false , [personal] = null...

filtered out true values

...and create distinct list of names counts of number of times each name appears in previous table:

distinct list of names count field

*displaying [order complete] , [personal] fields redundant point , dropped simplify.

i can steps individually above, struggling single query all... appreciated!

thanks in advance,

-tim

this should following

select dbo.tblperson.person,        count(dbo.tblperson.person) count   dbo.tblperson inner join dbo.tblnotifications on dbo.tblperson.personid = dbo.tblnotifications.addresseeid  dbo.tblnotifications.complete = 'false'    , dbo.tblnotifications.personal null group dbo.tblperson.person order count(dbo.tblperson.person) desc 

you don't need distinct or top 100 percent,

here simplified fiddle


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -