Solved

Top Number of Record in SQL

Posted on 2003-12-05
15
407 Views
Last Modified: 2010-05-01
Hello All,

Is there anyway to select the (Top 10 Records) based on the CountOfSummaryItem in the following SQL?

s_Sql = "SELECT DAuthor, Count(DAuthor) As CountOfSummaryItem, _
        (Count(*)/(Select count(*) FROM tbl_Records_DR)) as Percentage _
        From tbl_Records_DR GROUP BY DAuthor Order BY DAuthor;"

Thanks guys. ADawn
0
Comment
Question by:ADawn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 3
  • +2
15 Comments
 
LVL 33

Expert Comment

by:hongjun
ID: 9882820
try this

s_Sql = "SELECT TOP 10 DAuthor, Count(DAuthor) As CountOfSummaryItem, _
        (Count(*)/(Select count(*) FROM tbl_Records_DR)) as Percentage _
       From tbl_Records_DR GROUP BY DAuthor Order BY DAuthor;"
0
 
LVL 10

Accepted Solution

by:
ADSaunders earned 60 total points
ID: 9882830
Hi ADawn,
> s_Sql = "SELECT DAuthor, Count(DAuthor) As CountOfSummaryItem, _
>         (Count(*)/(Select count(*) FROM tbl_Records_DR)) as Percentage _
>         From tbl_Records_DR GROUP BY DAuthor Order BY DAuthor;"
s_Sql = "SELECT TOP 10 DAuthor, Count(DAuthor) As CountOfSummaryItem, _
        (Count(*)/(Select count(*) FROM tbl_Records_DR)) as Percentage _
        From tbl_Records_DR GROUP BY DAuthor Order BY CountOfSummaryItem DESC;"


Regards .. Alan
0
 
LVL 33

Expert Comment

by:hongjun
ID: 9882847
The keyword is to use
    TOP 10


hongjun
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9882855
hearing...
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 9882894
Richie Simonetti what does that mean?   hearing.... or listening......
0
 
LVL 33

Expert Comment

by:hongjun
ID: 9882907
he meant he is listening to this question to learn something.
he just wish to be subscribed to this question.

Actually to subscribe to this question, one can simply click on the "Subscribe" link.

hongjun
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9882919
:)
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 9882938
ohhh thanks.... good to know is that an EE standard of Terminology??
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9882950
Sometimes i have no time to post comments, sometimes i would like to know how it ends, sometimes i don't know what to say, sometimes just curious.
0
 
LVL 33

Expert Comment

by:hongjun
ID: 9882951
>> is that an EE standard of Terminology??
Ya that has been a term used and many understand it (at least in EE).
Some other terms are like
listening
hearing
ping
...


hongjun
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9882960
you forgot one:
learning...
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 9882973
Thanks guys
0
 
LVL 33

Expert Comment

by:hongjun
ID: 9882994
I know I got to be careful when talking to a veteran expert so I used ... at the end ;)

hongjun
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9883421
Hey, i am not too old!!
0
 

Author Comment

by:ADawn
ID: 9888136
Thanks ADSaunders! ADawn
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question