Azure Streaming Analytics Query: Select latest data only

Bhinge, Rahul 1 Reputation point
2020-06-17T16:11:53.333+00:00

Hi All,

I have very basic SQL experience and i'm a little stuck, so any help is appreciated.

I'm working on a way to stream status of some jobs that are running on an HPC resource (sort of like trying to create a dashboard to look at real time flight status). I generate and push data every 60 seconds. Unfortunately, this way i end up with a lot of repeated data as the status of each 'job' changes unpredictably. I need a way to only keep the latest data.

I've attached some images of my data. Essentially i just want to select the rows that represent the last timestamp and nothing else.

Here is my query so far:

SELECT
Job, Ref, Location, Queue, Description, Status, ElapTime, cast (Time as datetime) as Time
INTO
output_source
FROM
input_source

Thanks!

10236-query-output.p![10247-query-output.pngng]1

Azure Stream Analytics
Azure Stream Analytics
An Azure real-time analytics service designed for mission-critical workloads.
354 questions
{count} votes

1 answer

Sort by: Most helpful
  1. HimanshuSinha-msft 19,476 Reputation points Microsoft Employee
    2020-06-22T16:38:10.07+00:00

    Hello ,
    Welcome to the Q&A .

    Your goal is to get the latest data , I think you can use the max aggregate function and the belwo query should be helpful . I have not tested the query but it should give you the idea . In case if you ran into issue , please do let us know .

    SELECT
    Job, Ref, Location, Queue, Description, Status, ElapTime, max(cast (Time as datetime)) as Time
    INTO
    output_source
    FROM
    input_source
    GROUP BY Job, Ref, Location, Queue, Description, Status, ElapTime
    

    Thanks & stay safe

    Himanshu

    Please do consider to click on "Accept Answer" and "Up-vote" on the post that helps you, as it can be beneficial to other community members


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.