Solved

Top Number of Record in SQL

Posted on 2003-12-05
15
397 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

919 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now