question

azafra99 avatar image
azafra99 asked

I am trying to create a data export file. The data comes from multiple tables. I am stuck on trying to grab reading data from a history table.

My query below returns multiple results for RadioNumber 0001. I only want the last result from day before. One record per RadioNumber

select distinct(RadioNumber), MAX(ArrivalDate),Reading

from mytable where ArrivalDate >= DATEADD(day, -1, convert(date, GETDATE()))

Group by Reading,RadioNumber

Results:
RadioNumber | ArrivalDate | Reading

0001 | 09/18/2018 | 123456

0001 | 09/17/2018 | 234567

0002 | 09/18/2018 | 345678

0003 | 09/18/2018 | 456789

resultshistorylastper
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.