473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

SQL SELECT TOP question

I need to select the Top 50 records from a table of over 10,000 records and
all is working just fine, but I have a what if question.

What if the 50th record's value matches the 51st record (and possible the
52nd and so on)? Does the Select Command also include those records or no?
If not, how is the 50th record determined?

Thanks for the information.

Brad

Nov 21 '05 #1
4 4881
"Brad" <ba******@ukcdogs.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I need to select the Top 50 records from a table of over 10,000
records and all is working just fine, but I have a what if question.

What if the 50th record's value matches the 51st record ... ?


"Top 50" is perhaps a misnomer - it should more accurately be "First 50".

Your database will return the first 50 records contained in the data set
and nothing more, regardless of value.

HTH,
Phill W.
Nov 21 '05 #2
Phill,

Thank you for the explaination.

Is there a way to grab those other few records that might match the 50th
value? Is there special syntax in the SQL statement or is this a programming
issue?

Thanks again.

Brad
"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message
news:ct**********@yarrow.open.ac.uk...
"Brad" <ba******@ukcdogs.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I need to select the Top 50 records from a table of over 10,000
records and all is working just fine, but I have a what if question.

What if the 50th record's value matches the 51st record ... ?


"Top 50" is perhaps a misnomer - it should more accurately be "First 50".

Your database will return the first 50 records contained in the data set
and nothing more, regardless of value.

HTH,
Phill W.

Nov 21 '05 #3
TOP n [PERCENT]

Specifies that only the first n rows are to be output from the query result
set. n is an integer between 0 and 4294967295. If PERCENT is also specified,
only the first n percent of the rows are output from the result set. When
specified with PERCENT, n must be an integer between 0 and 100.

If the query includes an ORDER BY clause, the first n rows (or n percent of
rows) ordered by the ORDER BY clause are output. If the query has no ORDER
BY clause, the order of the rows is arbitrary.

chanmm
"Brad" <ba******@ukcdogs.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I need to select the Top 50 records from a table of over 10,000 records and
all is working just fine, but I have a what if question.

What if the 50th record's value matches the 51st record (and possible the
52nd and so on)? Does the Select Command also include those records or
no? If not, how is the 50th record determined?

Thanks for the information.

Brad

Nov 21 '05 #4
This would have to be done in a Stored Procedure or Client side.

Chris

"Brad" <ba******@ukcdogs.com> wrote in message
news:OU**************@TK2MSFTNGP11.phx.gbl...
Phill,

Thank you for the explaination.

Is there a way to grab those other few records that might match the 50th
value? Is there special syntax in the SQL statement or is this a
programming issue?

Thanks again.

Brad
"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message
news:ct**********@yarrow.open.ac.uk...
"Brad" <ba******@ukcdogs.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I need to select the Top 50 records from a table of over 10,000
records and all is working just fine, but I have a what if question.

What if the 50th record's value matches the 51st record ... ?


"Top 50" is perhaps a misnomer - it should more accurately be "First 50".

Your database will return the first 50 records contained in the data set
and nothing more, regardless of value.

HTH,
Phill W.


Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mohammed Mazid | last post by:
Hi folks! Can anyone please help me with this? I am developing a Quiz program but I am stuck with "multiple answers". Basically I need some sort of code that would select multiple answers...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
2
by: marco | last post by:
Dear List, as it seems, MS SQL as used in Access does not allow a select INTO within a UNION query. Also, it seems that a UNION query can not be used as a subquery. Maybe my (simplified)...
6
by: @sh | last post by:
Need help again! Here's the head script... ---------------------------------------------------------------------------------------- function Ash_ChangePicFromSelect(TheSource,TheDestination) {...
1
by: Christopher DeMarco | last post by:
Hi all... I've written a class to provide an interface to popen; I've included the actual select() loop below. I'm finding that "sometimes" popen'd processes take "a really long time" to...
5
by: GTi | last post by:
Whats wring with this code? <select class=EditField size="1" name="PlantUnitID" title="Select line"> <option value="0" >Standalone Unit</option> <option value="1" selected >Connected Unit...
2
by: Eitan | last post by:
Hello, I want a solutions for a compicateds sql select statments. The selects can use anything : views, stored procedures, analytic functions, etc... (not use materialized view, unless it is...
21
beacon
by: beacon | last post by:
Hello to everybody, I have a section on a form that has 10 questions, numbered 1-10, with 3 option buttons per question. Each of the option buttons have the same response (Yes, No, Don't know),...
17
by: trose178 | last post by:
Good day all, I am working on a multi-select list box for a standard question checklist database and I am running into a syntax error in the code that I cannot seem to correct. I will also note...
25
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if my question needs to be here or in coldfusion. If i have my question is in the wrong section i am sorry in advance an will move it to the correct section. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.