Reputation: 3749
How to return only the values that are in yellow in a SQL query for Access? I have not found a logic.
Upvotes: 0
Views: 90
Reputation: 810
SELECT *
FROM YourTable1
WHERE DataFim = '08/10/2013'
Use the above if it is a string column.
If it is a datetime or date column you can use:
SELECT *
FROM YourTable1
WHERE DataFim = CONVERT(DATETIME, '08/10/2013')
If you need to find all for the latest date that was entered as your comment implies, use:
SELECT *
FROM YourTable1
WHERE DataFim IN (SELECT MAX(DataFim) FROM YourTable1)
Just for reference, if you didn't want to use MAX()
, you could replace the last line with
WHERE DataFim IN (SELECT TOP 1 DataFim FROM YourTable1 ORDER BY DataFim DESC)
Which has the same effect but would also work on getting a string that is last when sorted alphabetically.
Upvotes: 1
Reputation: 4808
Given your reply to Amber...
SELECT * FROM TableName
WHERE DataFim IN (SELECT MAX(DataFim) FROM TableName);
Upvotes: 0