472,119 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

using count with top

Bam
hey gang.

i am trying to pull a count from the top 16 records in a db.

select count(top 16 (username)) as cnt2 from bracketdb_"&tourney_id&" where
username <'BYE' order by POS

this is what i need to do, however, it doesn't work. i am getting a systax
error near TOP.
this is using SQLdb

any ideas?

thanks
bam
May 27 '07 #1
2 3705
Bam wrote:
hey gang.

i am trying to pull a count from the top 16 records in a db.

select count(top 16 (username)) as cnt2 from bracketdb_"&tourney_id&"
where username <'BYE' order by POS

this is what i need to do, however, it doesn't work. i am getting a
systax error near TOP.
Well Duhh! :-)
Do you have Books OnLine (BOL)? If not, see:
http://www.aspfaq.com/show.asp?id=2229
this is using SQLdb
I'm not clear. Is there a possibility that the count could be LESS than 16??
It will never be more than 16, right? Try this:

Select count(*) from (select top 16 username from ... ) as q

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
May 28 '07 #2
Bam
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomwrote in message
news:u0**************@TK2MSFTNGP04.phx.gbl...
Bam wrote:
>hey gang.

i am trying to pull a count from the top 16 records in a db.
I'm not clear. Is there a possibility that the count could be LESS than
16?? It will never be more than 16, right? Try this:

Select count(*) from (select top 16 username from ... ) as q
yes and yes. it can be less than 16, but never more.

i used what you put there, and it seems to work fine.

Thanks once again Bob
May 28 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by kingster | last post: by
8 posts views Thread by Andrew Robinson | last post: by
4 posts views Thread by onecorp | last post: by
3 posts views Thread by amitsoni.1984 | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.