Skip to content
Advertisement

How do I query sql for a latest version of a record in the same date

I am trying to perform a query that returns the value of the last published version. The versions can be named V1, V2, R1_V1, R1_V2, R2_V1, R2_V2 and are published in this order. The first post will always be #null. Not all versions are dependent, I mean, the first version of the day can be registered as R1_V1 without first publishing V1 and V2.

Versions contain hourly logs, that’s why I require to always take the latest version.

Here is a brief example:

sample

Advertisement

Answer

Next time, paste your input data as text into your question. I had to manually re-type everything ….

You need an additional sorting value, in addition to the version; then, you need to add a filter value based on the sorting order. Use an OLAP function.

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