View Full Version : GROUP BY


fordy
04-10-2002, 08:05 AM
SELECT [Table1 Query].[STOCK VALUE], Max([NUMBER]) AS MaxDate
FROM [Table1 Query];
WHERE Group By [STOCK VALUE]

What I want is the most recent STOCK VALUE, from the last record, to be showed. But this doesnt seem to have worked. Can anyone help me

RV
04-10-2002, 08:17 AM
It's either a WHERE clause or a GROUP BY command:

SELECT [Table1 Query].[STOCK VALUE], Max([NUMBER]) AS MaxDate
FROM [Table1 Query]
GROUP BY [STOCK VALUE];

Put always the ; sign AT THE END of a statement.
I don't know how your database has been designed. Try this, come back if you need further assistance.

Suc6,

RV

Pat Hartman
04-10-2002, 08:57 AM
Since every value of [NUMBER] is likely to have a different value of [STOCK VALUE], the query as it is written will not work. You need to either break it into two queries and nest one within the other or use a sub select:

SELECT [Table1 Query].[STOCK VALUE]
FROM [Table1 Query]
Where [NUMBER] = (Select Max([NUMBER]) From Table1 Query]);

fordy
04-10-2002, 09:00 AM
Im only a novice, is there any way in which you, only see the result of the latest query instead of it giving you all the records, thanks for your help