You are here: Re: COUNT many but display just once? « MsSQL Server « IT news, forums, messages
Re: COUNT many but display just once?

Posted by Greg D. Moore \(Strider\) on 04/23/07 00:23

"Erik Lautier" <lautier@gmail.com> wrote in message
news:1177283677.045638.109480@o5g2000hsb.googlegroups.com...
> Hi, I have a table that I insert a member's country into every time
> someone signs up. What I'd like to do is pull information from the DB
> such that I can see each country and the number of users from each.
> For example:
>
> Argentina 10
> Brazil 5
> Canada 3

W/o schema it's impossible to say what you want for sure but something like


create table membership
(
country varchar(20),
signup varchar(20)
);

insert into membership values ('Argentina', 'member 1')
insert into membership values ('Argentina', 'member 2')
insert into membership values ('Brazil', 'member 1')
insert into membership values ('Brazil', 'member 1')
insert into membership values ('Brazil', 'member 2')
insert into membership values ('Brazil', 'member 3')
insert into membership values ('Canada', 'member 1')

select country, count(signup) from membership group by country


SELECT COUNTRY, COUNT(signup) from membership group by country


>
> I'm having trouble writing the SQL for this...any suggestions?
>
> Thanks,
>
> Erik
>

--
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация