getting the latest 6 record information

  • Thread starter Thread starter alvarjo9
  • Start date Start date
A

alvarjo9

Hi,
Please kindly help . I am trying to report the latest 6 records for a
particular query example below based on the date. In my report I should only
display records from Apr 4 to Apr 10. Please help to assist.

Category A
1 Apr,
3 Apr
4 Apr
5 APr
8 Apr
9 Apr
10 Apr
12 Apr
 
alvarjo9 said:
Please kindly help . I am trying to report the latest 6 records for a
particular query example below based on the date. In my report I should only
display records from Apr 4 to Apr 10. Please help to assist.

Category A
1 Apr,
3 Apr
4 Apr
5 APr
8 Apr
9 Apr
10 Apr
12 Apr


SELECT TOP 6 table.*
FROM table
ORDER BY datefield DESC
 
Hi ,
Thanks for the help. I am running this query:
SELECT TOP 6 Scores.Name, Scores.Date
FROM Scores
GROUP BY Scores.Name, Scores.Calibre
ORDER BY Scores.Date DESC;

basically it has around 500 members and I need to extract each member who has
the latest 6 information based on the latest Date. One member has 6
catergories (A to F) and I need to query each member with their latest six
date of activity for each of their category(A to F) but when i ran the query
above I had an eror of "you tried to execute a query that does not have the
specified expression
"date" as part of an aggregate function.

Please kindly help/assist.

thanks & regards,
Jonathan
Marshall said:
Please kindly help . I am trying to report the latest 6 records for a
particular query example below based on the date. In my report I should only
[quoted text clipped - 9 lines]
10 Apr
12 Apr

SELECT TOP 6 table.*
FROM table
ORDER BY datefield DESC
 
alvarjo9 said:
I am running this query:
SELECT TOP 6 Scores.Name, Scores.Date
FROM Scores
GROUP BY Scores.Name, Scores.Calibre
ORDER BY Scores.Date DESC;

basically it has around 500 members and I need to extract each member who has
the latest 6 information based on the latest Date. One member has 6
catergories (A to F) and I need to query each member with their latest six
date of activity for each of their category(A to F) but when i ran the query
above I had an eror of "you tried to execute a query that does not have the
specified expression
"date" as part of an aggregate function.


TOP does not mesh well with GROUP BY.

In this case, you need to use TOP in a subquery:

SELECT Scores.Name, Scores.Date, Scores.Calibre
FROM Scores
WHERE Scores.Date IN(SELECT TOP 6 X.Date
FROM Scores As X
WHERE X.Name = Scores.Name
And X.Calibre = Scores.Calibre)
 

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

Back
Top