Jump to content
Server Maintenance This Week. ×

Highest of related records from 3 tables


This topic is 1587 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have a parent table which has 3 child tables all of which have a date field.

I would like to have a field in the parent table which tells me what is the latest date in the 3 child tables so I know the last time there was activity relating to the parent record.

I can figure it out.

 

Link to comment
Share on other sites

You could use a calculation =

Max ( 
Max ( ChildTableA::Datefield ) ; 
Max ( ChildTableB::Datefield ) ; 
Max ( ChildTableC::Datefield ) 
)

However, if you have 3 child tables that are alike in that you need to know the latest date in all three, then maybe they should be consolidated into one.

 

  • Like 1
Link to comment
Share on other sites

Follow-up question, please:

Say, in the child table, there's a Description (text) field. While Max (ChildTableA::Datefield) will grab the latest date (from Table A), how would you grab the contents from the latest date's accompanying Description field as well?

Edited by Rich
grammar police
Link to comment
Share on other sites

If it's for display only, you could use a one-row portal sorted by date, descending (or filtered to show only the most recent record), with any combination of fields.

If you need it at the data level (e.g. for further calculations), you may be able to use the Last() function; this will get the data from the last record (in the sort order of the relationship) where the description field is not empty. For another option see:
https://www.briandunning.com/cf/908

 

Edited by comment
Link to comment
Share on other sites

This topic is 1587 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.