0

I have 2 tables:

  • TenantServer
  • Result

The [TenantServer] has a 1-to-Many relationship with the [Result] table. As a TenantServer can have multiple Results. An example below shows the TenantServer (DBName) column with multiple Results (Type and Date).

enter image description here

What I'm trying to do is get the 1 latest row foreach DBName and Type, for example:

WintrixVictorMillwell, Log, (date here)

WintrixRAC, Log, (date here)

WintrixComfort, Log, (date here)

Each DBName can have 2 different types also, these are "Log" and "Full"

I'm not sure how I would acheive this, so far I've been able to get the latest rows since the last 24 hours but i cant seem to figure out how to get 1 latest row for each of them.

KTOV
  • 559
  • 3
  • 14
  • 39
  • `Max(DATE)` and remove Date from the `Group By` and `Order By` – SS_DBA Nov 08 '17 at 21:30
  • @WEI_DBA Can you post an answer please, because I'm not sure what you mean> – KTOV Nov 08 '17 at 21:37
  • `Select DBName, [Type], MAX([Date]) ... ` and remove `[Date]` From the `Group By` clause and `Order By` clause. Also, look at the link it's been answered many times over.. https://stackoverflow.com/questions/7745609/sql-select-only-rows-with-max-value-on-a-column – SS_DBA Nov 08 '17 at 21:45

0 Answers0