B
Bob Vance
Can I sort my query so only the records with the Oldest date is to be shown
Can I sort my query so only the records with the Oldest date is to be shown
Thanks Arvin, Is it possible only to show one record even if there is 6Arvin Meyer said:Yes, use Ascending order. If you want the oldest records, use the TOP
predicate as in:
SELECT TOP 25 *
FROM MyTable
ORDER BY DateField;
Which will select the oldest 25 records.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
Bob Vance said:Thanks Arvin, Is it possible only to show one record even if there is 6Arvin Meyer said:Yes, use Ascending order. If you want the oldest records, use the TOP
predicate as in:
SELECT TOP 25 *
FROM MyTable
ORDER BY DateField;
Which will select the oldest 25 records.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
records with the Oldest dates..Regards Bob
SELECT TOP 1 Format([dtDate],"mmmm"", ""yyyy") AS HoldDate, *
FROM tblInvoice_ItMdt
ORDER BY tblInvoice_ItMdt.dtDate DESC;
Ken Snell said:Assuming you have a primary key in the table:
SELECT Format([dtDate],"mmmm"", ""yyyy") AS HoldDate, *
FROM tblInvoice_ItMdt
WHERE PrimaryKeyField =
(SELECT T.Min(PrimaryKeyField) AS MinPK
FROM tblInvoice_ItMdt AS T
WHERE T.dtDate =
(SELECT Min(U.dtDate) AS Mindt
FROM tblInvoice_ItMdt AS U));
--
Ken Snell
http://www.accessmvp.com/KDSnell/
Bob Vance said:Thanks Arvin, Is it possible only to show one record even if there is 6Arvin Meyer said:Yes, use Ascending order. If you want the oldest records, use the TOP
predicate as in:
SELECT TOP 25 *
FROM MyTable
ORDER BY DateField;
Which will select the oldest 25 records.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
Can I sort my query so only the records with the Oldest date is to be
shown
records with the Oldest dates..Regards Bob
SELECT TOP 1 Format([dtDate],"mmmm"", ""yyyy") AS HoldDate, *
FROM tblInvoice_ItMdt
ORDER BY tblInvoice_ItMdt.dtDate DESC;
Thanks Arvin, Is it possible only to show one record even if there is 6
records with the Oldest dates..Regards Bob
SELECT TOP 1 Format([dtDate],"mmmm"", ""yyyy") AS HoldDate, *
FROM tblInvoice_ItMdt
ORDER BY tblInvoice_ItMdt.dtDate DESC;
Arvin Meyer said:Of course that assumes that the Primary Key is an incremental field like
an autonumber. <g>
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
Ken Snell said:Assuming you have a primary key in the table:
SELECT Format([dtDate],"mmmm"", ""yyyy") AS HoldDate, *
FROM tblInvoice_ItMdt
WHERE PrimaryKeyField =
(SELECT T.Min(PrimaryKeyField) AS MinPK
FROM tblInvoice_ItMdt AS T
WHERE T.dtDate =
(SELECT Min(U.dtDate) AS Mindt
FROM tblInvoice_ItMdt AS U));
--
Ken Snell
http://www.accessmvp.com/KDSnell/
Bob Vance said:Yes, use Ascending order. If you want the oldest records, use the TOP
predicate as in:
SELECT TOP 25 *
FROM MyTable
ORDER BY DateField;
Which will select the oldest 25 records.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
Can I sort my query so only the records with the Oldest date is to be
shown
--
Thanks in advance for any help with this......Bob
MS Access 2007 accdb
Windows XP Home Edition Ver 5.1 Service Pack 3
Thanks Arvin, Is it possible only to show one record even if there is 6
records with the Oldest dates..Regards Bob
SELECT TOP 1 Format([dtDate],"mmmm"", ""yyyy") AS HoldDate, *
FROM tblInvoice_ItMdt
ORDER BY tblInvoice_ItMdt.dtDate DESC;
Arvin Meyer said:As Ken mentioned, you can then get a record from the Primary Key field.
But unless the Primary Key is an autonumber, you cannot guarantee that it
will actually be the first.
Ken Snell said:Actually it doesn't matter what datatype the primary key field is. The Min
function will work on any data type.