Microsoft
Software
Hardware
Network
Question : Access: How to write a query with DISTINCT
Hi X-perts,
I have a table with fields (fund_id, value, date). it presents multiple rows for the same fund_id (but different date and value). I need to write a query that selects distinct fund_id and its corresponding date and value (the last possible date value).
SELECT DISTINCT fund_id FROM historydetail ===> works OK and takes unique fund_id
SELECT DISTINCT fund_id,value FROM historydetail ======> takes not unique fund_id, but unique fund_id+value combinations, i.e. I am getting multiple fund_id rows.
How can I select UNIQUE fund_id and their corresponding value (the last date)?
Please, advise.
thanks
Answer : Access: How to write a query with DISTINCT
SELECT t1.fund_id, t1.[value]
FROM historydetail t1 INNER JOIN
(SELECT t2.fund_id, Max(t2.EndDate) AS LastDate
FROM historydetail t2
GROUP BY t2.fund_id) AS q ON t1.fund_id = q.fund_id And t1.EndDate = q.LastDate
Random Solutions
Outlook 2007 connecting to Exchange 2010. Cannot connect to email folders.
Received error "ActiveX component can't create object" while calling WinFax.SDKSend in VBA
Click event overrides DblClick event
Is there a way of inserting hyphens (-) into all of the existing phone numbers contained in my Outlook 2007 contacts list? So the format will be 123-456-7890 instead of 1234567890
Loading images from directory into 5 Pictureboxes HOW?
Generic path to open a file from VBA
SQL Select problem...need records with "best match" returned in order
ASPIRE 5732z Acer - password
SSRS - How can I increase a multi-value param dropdown? Got to be a way
Using runtime themes on XP Embedded