By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,061 Members | 1,563 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,061 IT Pros & Developers. It's quick & easy.

How to select the last 3 records?

P: 58
I have a query that selects any records in a table that have to do with units ordered. I would like to have a nested query that then selects the last three records from the above query.

Here is the sql from my current query:

SELECT [Inventory Transactions].TransactionDate, [Inventory Transactions].UnitsOrdered
FROM [Inventory Transactions]
WHERE ((([Inventory Transactions].UnitsOrdered)>1));

And here is a sample of the data that query produces:

Transaction Date Units Ordered
1/1/2007 1000
1/1/2007 10751
1/31/2007 4726
1/31/2007 1921
2/6/2007 1101
2/6/2007 6950

Now I would like to be able to display the last (based on date) three of these records into a form, I was thinking that with a nested query I could accomplish this. Please lend me any help.

If there is a better way to accomplish this whole thing please let me know. I don't know if maybe there is a better way to select the most recent three records with values in 'Units Ordered' from the original table.

Anyway, Thank you all in advance.
Feb 13 '07 #1
Share this Question
Share on Google+
1 Reply

P: 176
Expand|Select|Wrap|Line Numbers
  1. SELECT TOP 3 [Inventory Transactions].TransactionDate, [Inventory Transactions].UnitsOrdered
  2. FROM [Inventory Transactions]
  3. WHERE ((([Inventory Transactions].UnitsOrdered)>1))
  4. ORDER BY [Inventory Transactions].TransactionDate DESC;
Feb 13 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.