Skip to content
Advertisement

Get Latest ModifiedDate Joining Multiple Tables

I have 4 tables

  1. ProjectTable

  2. ProjectFinalizeTable

  3. ProjectAdditionalTimeTable

  4. ProjectCompleteTable

Any of tables gets modified depending upon the user’s action. All tables have projectId as foreignKey from ProjectTable.

I want to get the latest modifiedDate from any of the table. Ex: ProjectFinalizeTable can have latest modifiedDate so that-date will be returned from the query.

To give you an idea what I want is like below query (Note: below query is just to give you idea about what exactly I am looking for)

I have gone through many links but can’t find a way to calculate MAX(Date) from multiple tables.

Advertisement

Answer

Given you want the max(modifiedDate) over a number of tables, it would seem that unioning them and the aggregating them is the way to go.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement