Skip to content
Advertisement

SQL – Column containing current firmware string based on occational messages with several machines

I have a table called SessionEvents.

SessionEvents

I’m trying to create a column that represents the firmware that is on the machine to later be able to filter messages for only certain software.

Currently my SQL query looks like this. (Based on answer by adamlamar in How do I efficiently select the previous non-null value? with slight modifications.)

I’m using JOIN in since machine_id is in a related table called Sessions.

This works for a single machine but i cant find a way to implement this properly for several machines. How should i modify the query to adopt if for several machines?

(Data is fetched from Azure SQL database)

Advertisement

Answer

This is a gaps-and-islands problem. First define the islands, then spread the firmware:

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