BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Top N for each group

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Michael Luna
Guest





PostPosted: Wed Oct 06, 2004 7:24 am    Post subject: Top N for each group Reply with quote



I need the top 25 voters in each precinct in a district.


Select prec, voterid, hh_cnt, vcnt
group by precinct
where hh_cnt * vcnt


Back to top
Wayne Niddery [TeamB]
Guest





PostPosted: Wed Oct 06, 2004 2:41 pm    Post subject: Re: Top N for each group Reply with quote



Michael Luna wrote:
Quote:
I need the top 25 voters in each precinct in a district.

Select prec, voterid, hh_cnt, vcnt
group by precinct
where hh_cnt * vcnt

In what order? Add an appropriate order by clause.

What database? Different databases can be handled different ways.

--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"The legitimate powers of government extend to such acts only as are
injurious to others. But it does me no injury for my neighbor to say
there are twenty gods, or no God. It neither picks my pocket nor breaks
my leg." - Thomas Jefferson



Back to top
Michael Luna
Guest





PostPosted: Thu Oct 07, 2004 1:08 am    Post subject: Re: Top N for each group Reply with quote



My bad
Select prec, voterid, hh_cnt, vcnt
group by precinct
ORDER BY hh_cnt * vcnt

Data base is MS SQL

"Wayne Niddery [TeamB]" <wniddery (AT) chaffaci (DOT) on.ca> wrote

Quote:
Michael Luna wrote:
I need the top 25 voters in each precinct in a district.

Select prec, voterid, hh_cnt, vcnt
group by precinct
where hh_cnt * vcnt

In what order? Add an appropriate order by clause.

What database? Different databases can be handled different ways.

--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"The legitimate powers of government extend to such acts only as are
injurious to others. But it does me no injury for my neighbor to say
there are twenty gods, or no God. It neither picks my pocket nor breaks
my leg." - Thomas Jefferson





Back to top
Wayne Niddery [TeamB]
Guest





PostPosted: Thu Oct 07, 2004 1:50 pm    Post subject: Re: Top N for each group Reply with quote

Michael Luna wrote:
Quote:
My bad
Select prec, voterid, hh_cnt, vcnt
group by precinct
ORDER BY hh_cnt * vcnt

Data base is MS SQL

select top 25 ...

--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
It used to be that other people's achievements were considered an
inspiration, not a grievance.



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.