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:
i'd single sql query filter (select...where...) considering records [order complete] = false , [personal] = null...
...and create distinct list of names counts of number of times each name appears in previous table:
*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
Post a Comment