sql - count repeated records in a table of a specific column -


i newbie sql server, need value of how many times repeat value in column, , group number of times repeated, location.

i mean:

table activity id     orderid      location       date     x      order11       newyork      xxxx      x      order22       miami        xxxx     x      order11       la           xxxx x      order33       newyork      xxxx    x      order11       newyork      xxxx x      order22       miami        xxxx x      order22       newyork      xxxx x      order44       miami        xxxx 

i have this:

select [orderid], count(1) countorder [mobileservice].[activity] group [orderid] order countorder desc 

and returns me:

orderid       countorder      order11       3 order22       3 order33       1 order44       1 

ok, good, but, want filter location

select [newsitemtitle], count(1) xx [mobileserviceextra].[activity] group [newsitemtitle] order xx desc [location] = 'newyork' 

and returns me incorrect syntax near keyword 'where'.

so, want following result if filter newyork

orderid      countorder         order11      2          order22      1 order33      1 

how can fix ?

you close had order wrong:

select [newsitemtitle], count(1) xx [mobileserviceextra].[activity] [location] = 'newyork' group [newsitemtitle] order xx desc 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -