Hello,
Hours passed and whereas I looked many posts on the web, I don't find any source of help to resolve my problem.
I wish to make data treatment in order to extract of maximum value of an ID for each line containing date range. Sometimes, graphics tell more that text, you will find it in attachment!
For that, I've already created a new view that out a date range (start/end) of a specific phase for each production Batch.
Then, I would like to extract a Max Value for Tagname ID in history table for each Batch, using the date range and the tagname.
Today my request is the following but if there is no error (youpi), there is no results!
SELECT dbo.V_DatesRincagesNep.Batch_Log_ID, dbo.V_DatesRincagesNep.DateTimeStart, dbo.V_DatesRincagesNep.DateTimeEnd, MAX(Runtime.dbo.v_History.Value) AS MaxValCond
FROM dbo.V_DatesRincagesNep LEFT OUTER JOIN
Runtime.dbo.v_History ON Runtime.dbo.v_History.DateTime BETWEEN dbo.V_DatesRincagesNep.DateTimeStart AND dbo.V_DatesRincagesNep.DateTimeEnd
GROUP BY dbo.V_DatesRincagesNep.DateTimeStart, dbo.V_DatesRincagesNep.DateTimeEnd, dbo.V_DatesRincagesNep.Batch_Log_ID, Runtime.dbo.v_History.TagName
HAVING (Runtime.dbo.v_History.TagName = 'NE5547_CIT_320.fMesure')
The sample data are following:
History data
DateTime TagName Value
2024-05-06 00:00:00.0000000 NE5547_FIT_003.fMesure -0.00520833348855376
2024-05-06 00:00:00.0000000 NE5547_FQIT_001.fMesure 1282
2024-05-06 00:00:00.0000000 NE5547_LT_001.fMesure -0.217013895511627
2024-05-06 00:00:00.0000000 NE5547_COMPTAGE_PH002_EPU.fMesure 951910.625
2024-05-06 00:00:00.0000000 NE5547_COMPTAGE_PH002_CYCLE.fMesure 3925
2024-05-06 00:00:00.0000000 NE5547_FQIT_003.fMesure 725
2024-05-06 00:00:00.0000000 NE5547_FQIT_002.fMesure 0
2024-05-06 00:00:00.0000000 NE5547_COMPTAGE_PH003_EPU.fMesure 1557940
2024-05-06 00:00:00.0000000 NE5547_COMPTAGE_PH003_CYCLE.fMesure 5403
2024-05-06 00:00:00.0000000 NE5547_COMPTAGE_JJ.fMesure 1
Table Batch with date-ranges
Batch_Log_ID UnitOrConnection DateTimeStart DateTimeEnd
1K2FWV6VZX NE554801 2024-01-12 08:31:58.000 2024-01-12 08:57:43.000
1K2FX7N4X9 NE554801 2024-01-12 10:09:47.000 2024-01-12 10:25:21.000
1K2FXEEYGS NE554701 2024-01-12 11:23:38.000 2024-01-12 11:37:07.000
1K2HJ0TQ5L NE554801 2024-01-15 08:40:14.000 2024-01-15 08:53:16.000
1K2HJ4GF51 NE554701 2024-01-15 10:00:33.000 2024-01-15 10:21:33.000
1K2HJJE8UH NE554801 2024-01-15 11:32:44.000 2024-01-15 11:48:46.000
1K2HKBMHVZ NE554701 2024-01-15 16:29:34.000 2024-01-15 16:52:28.000
1K2I3F43LT NE554701 2024-01-16 09:42:28.000 2024-01-16 09:56:01.000
1K2I3FQLMK NE554801 2024-01-16 10:51:08.000 2024-01-16 11:03:55.000
1K2I3KS6E6 NE554701 2024-01-16 13:27:24.000 2024-01-16 14:14:22.000
My training and experiences are limited in SQL, and this subject is complex so I hope that I will find help!
Thank you very much for attention!
Pierre