 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Michael Luna Guest
|
Posted: Wed Oct 06, 2004 7:24 am Post subject: Top N for each group |
|
|
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
|
Posted: Wed Oct 06, 2004 2:41 pm Post subject: Re: Top N for each group |
|
|
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
|
Posted: Thu Oct 07, 2004 1:08 am Post subject: Re: Top N for each group |
|
|
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
|
Posted: Thu Oct 07, 2004 1:50 pm Post subject: Re: Top N for each group |
|
|
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 |
|
 |
|
|
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
|
|