SELECT Last N Records

S

shapper

Hello,

I need to load the last N records from a table.
The last N records are determined by date.
And I want N to be a parameter in the Query.
How can I do this?

I allready have a Query. The only thing I am missing is that part.

SELECT web_News.ArticleDate, web_NewsLocalized.ArticleTitle,
web_NewsLocalized.ArticleText
FROM web_News INNER JOIN web_NewsLocalized ON
web_News.ArticleId=web_NewsLocalized.ArticleId
WHERE ((web_NewsLocalized.ArticleCulture)=[@Culture]);

Thanks,
Miguel
 
G

Guest

I do not know your table structure so all I can do is explain the process.
Build a select query with the date descending and a ranking.
Use a criteria for the ranking like --
<= [Enter the required number of records]
 
G

Guest

For my "WeekID" field (short date format) I have the following as a criteria:
DateAdd("ww",-2,Date())

When you look at the list of records make sure you have what you need.

Hope this helps.

shapper said:
Hello,

I need to load the last N records from a table.
The last N records are determined by date.
And I want N to be a parameter in the Query.
How can I do this?

I allready have a Query. The only thing I am missing is that part.

SELECT web_News.ArticleDate, web_NewsLocalized.ArticleTitle,
web_NewsLocalized.ArticleText
FROM web_News INNER JOIN web_NewsLocalized ON
web_News.ArticleId=web_NewsLocalized.ArticleId
WHERE ((web_NewsLocalized.ArticleCulture)=[@Culture]);

Thanks,
Miguel
 
S

shapper

I am not sure I understood what you were saying but I tried this:

SELECT TOP [@N] web_News.ArticleDate ...

It didn't work.

Miguel

KARL said:
I do not know your table structure so all I can do is explain the process.
Build a select query with the date descending and a ranking.
Use a criteria for the ranking like --
<= [Enter the required number of records]

shapper said:
Hello,

I need to load the last N records from a table.
The last N records are determined by date.
And I want N to be a parameter in the Query.
How can I do this?

I allready have a Query. The only thing I am missing is that part.

SELECT web_News.ArticleDate, web_NewsLocalized.ArticleTitle,
web_NewsLocalized.ArticleText
FROM web_News INNER JOIN web_NewsLocalized ON
web_News.ArticleId=web_NewsLocalized.ArticleId
WHERE ((web_NewsLocalized.ArticleCulture)=[@Culture]);

Thanks,
Miguel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top