Solved

Export first 100 records from a table into Excel

Posted on 2008-10-07
3
236 Views
Last Modified: 2013-11-27
Hello,
I have created a table which is created from 2 append queries. I have indexed the table so field 'Total'
is in descending order. Will this stay in descending order all the time now?

My query is the table contains 22,000 entries and I only want the top 100 exported to Excel.
Is it possible to loop through the table to only paste the first 100 entries to Excel and forget
the rest?

Thanks
Ian
0
Comment
Question by:ShockUK
  • 2
3 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 22658594
you can get the top 100  using a query
the order by will determine which 100  you want to get

select top 100 *
from TableX
order by [fieldName]
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 22658604
Ian,

Create the query below, and export the query to Excel:

SELECT TOP 100 *
FROM SomeTable
ORDER BY Total DESC

Always use an ORDER BY clause if you need your results ordered in some way, because there is nothing
magical in the way records are physical ordered in memory.
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 22658612
(Will this stay in descending order all the time now?)
may or may not, but that is irrelevant . You can always sort them using a query.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

746 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

12 Experts available now in Live!

Get 1:1 Help Now