Skip to content
Advertisement

How to do an exact match on multiple columns and show with the latest date?

I want to only show one occurrences of an exact match of TempString1, TempString2, and TempString3 with the latest date. How can I do an exact match of three fields and only display the row that has the latest date?

Table

OUTPUT:

Advertisement

Answer

You can try this using ROW_NUMBER() function.

The ROW_NUMBER() is a window function that assigns a sequential integer to each row within a partition of a result set. The row number starts with one for the first row in each partition.

The following shows the syntax of the ROW_NUMBER() function:

Here is the live Demo on db<>fiddle.uk.

In below query the result of above query has been considered as table of name a

The result of both the query is as shown below. enter image description here

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