Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / June 2007

Tip: Looking for answers? Try searching our database.

Nested query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cmassari@gmail.com - 28 Jun 2007 22:25 GMT
Hello and thanks for reading my question.

The problem I have is that I want to query a table ad join it to
himself in a very particular way.

this is the table I have:

FUNDS
fund_name    date              value
-----------------------------------------------
fund_a          1/1/2001           30
fund_a          1/2/2001           32
fund_a          1/5/2001           35
fund_b          1/1/2001           17
fund_c          1/1/2001           23

Basically, what I need is to have an extra column in the result that
shows the value for the investement funds the previos day (not
necessary the PREVIOUS because samples might be missing but the newest
old value possible for the record date)

the result should look like this:

fund_name    date              value         prev_value
------------------------------------------------------------------------
fund_a          1/1/2001           30         null
fund_a          1/2/2001           32          30
fund_a          1/5/2001           35          32
fund_b          1/1/2001           17         null
fund_c          1/1/2001           23         null

Im having troubles to build this query in ms Access and I will really
appreciate if you can help me with it.

Regards from Argentina!

Cristian.
Allen Browne - 29 Jun 2007 03:50 GMT
Use a subquery to get the value for the matching fund from the most recent
date.

If subqueries are new, see:
   Subquery basics: Get the value in another record
at:
   http://allenbrowne.com/subquery-01.html#AnotherRecord

You will need to ensure that a fund doesn't have multiple values for the
same date. Also the query results will be read-only.

If you need an updatable query, you could use this lookup function instead:
   ELookup() - an extended replacement for DLookup()
at:
   http://allenbrowne.com/ser-42.html

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> Hello and thanks for reading my question.
>
[quoted text clipped - 33 lines]
>
> Cristian.
cmassari@gmail.com - 29 Jun 2007 14:33 GMT
Thank you very much for your help Allen!!!

Your site is on my favourite list now ;-)

Cristian.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.