Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 3 of 3 total |
Retreive the last ID from the details |
Tue, Feb 17 2015 2:49 PM | Permanent Link |
Beni | Hello,
Need some help with a query, procedure, view (would prefer), whatever solution: I have a master table ToDoList ID (PK) Description and detail table ToDoListHistory ID (PK) ToDoListID (FK - link to ToDoList.ID) EntryDate I would like to get a list of ToDoList items with the latest entry from the ToDoListHistory table: ToDoList: 1, First to do 2, Second to do ToDoListHistory: 1, 1, 2015-02-01 2, 1, 2015-02-05 3, 2, 2015-01-01 4, 2, 2015-02-12 ... and I would like to get the following result: ToDoList.ID, ToDoList.Description, ToDoListHistory.ID, ToDoListHistory.EntryDate 1, First to do, 2, 2015-02-05 2, Second to do, 4, 2015-02-12 |
Tue, Feb 17 2015 11:27 PM | Permanent Link |
Richard Harding Wise Nutrition Coaching | Hi Beni
How about? SELECT ToDoList.ID, ToDoList.Description, T1.ToDoListId, T1.MaxDate FROM ToDoList INNER JOIN (SELECT ToDoListID, MAX(EntryDate) AS MaxDate FROM ToDOListHistory GROUP BY ToDoListID) T1 ON T1.ToDoListID = ToDoList.ID Richard |
Wed, Feb 18 2015 1:14 PM | Permanent Link |
Beni | Yep! It does look like a solution!
Thanks! |
This web page was last updated on Monday, April 29, 2024 at 05:23 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |