Forum Discussion

dedelman_clng's avatar
dedelman_clng
Community Champion
2 months ago
Solved

Merge queries causing duplicate records

I am merging two queries together and it is creating duplicate records in the output. I have verified that there are no duplicates in either of the base queries as shown below

 

Table "States"

Valvetimestampstring_valuenameIndexTS-MSDt
XV0170452025-08-04T00:03:26.0110015-05:00UNDEFINEDPV_D194008/4/2025 12:03:26.0118/4/2025
XV0170452025-08-04T00:03:27.0070037-05:00CLOSEDPV_D194018/4/2025 12:03:27.0078/4/2025
XV0170452025-08-04T08:03:27.0070037-05:00CLOSEDPV_D194038/4/2025 08:03:27.0078/4/2025
XV0170452025-08-04T11:23:27.0070037-05:00CLOSEDPV_D194058/4/2025 11:23:27.0078/4/2025
XV0170452025-08-04T11:33:27.0070037-05:00CLOSEDPV_D194068/4/2025 11:33:27.0078/4/2025
XV0170452025-08-04T12:03:27.0070037-05:00CLOSEDPV_D194098/4/2025 12:03:27.0078/4/2025
XV0170452025-08-04T12:10:03.5070037-05:00OPENPV_D194118/4/2025 12:10:03.5078/4/2025
XV0170452025-08-04T12:50:58.5070037-05:00CLOSEDPV_D194138/4/2025 12:50:58.5078/4/2025
XV0170452025-08-04T20:50:58.5070037-05:00CLOSEDPV_D194158/4/2025 08:50:58.5078/4/2025

 

Table "RS Samples"

timestampnumeric_valuestring_valuewarningValveNmTS-MS
2025-08-04T00:03:26.0110015-05:00null0nullXV0170458/4/2025 12:03:26.011
2025-08-04T00:03:27.0070037-05:00null0nullXV0170458/4/2025 12:03:27.007
2025-08-04T08:03:27.0070037-05:00null0nullXV0170458/4/2025 08:03:27.007
2025-08-04T11:23:27.0070037-05:00null0nullXV0170458/4/2025 11:23:27.007
2025-08-04T11:33:27.0070037-05:00null0nullXV0170458/4/2025 11:33:27.007
2025-08-04T12:03:27.0070037-05:00null0nullXV0170458/4/2025 12:03:27.007
2025-08-04T12:10:03.5070037-05:00null1nullXV0170458/4/2025 12:10:03.507
2025-08-04T12:50:58.5070037-05:00null0nullXV0170458/4/2025 12:50:58.507
2025-08-04T20:50:58.5070037-05:00null0nullXV0170458/4/2025 08:50:58.507

 

Join (left outer) from States to RS Samples via Valve -> ValveNm and TS-MS -> TS-MS (TS-MS is a text datatype)

Result

Valvetimestampstring_valuenameIndexTS-MSDtRS Samples.string_value
XV0170452025-08-04T00:03:26.0110015-05:00UNDEFINEDPV_D194008/4/2025 12:03:26.0118/4/20250
XV0170452025-08-04T00:03:27.0070037-05:00CLOSEDPV_D194018/4/2025 12:03:27.0078/4/20250
XV0170452025-08-04T00:03:27.0070037-05:00CLOSEDPV_D194018/4/2025 12:03:27.0078/4/20250
XV0170452025-08-04T08:03:27.0070037-05:00CLOSEDPV_D194038/4/2025 08:03:27.0078/4/20250
XV0170452025-08-04T11:23:27.0070037-05:00CLOSEDPV_D194058/4/2025 11:23:27.0078/4/20250
XV0170452025-08-04T11:33:27.0070037-05:00CLOSEDPV_D194068/4/2025 11:33:27.0078/4/20250
XV0170452025-08-04T12:03:27.0070037-05:00CLOSEDPV_D194098/4/2025 12:03:27.0078/4/20250
XV0170452025-08-04T12:03:27.0070037-05:00CLOSEDPV_D194098/4/2025 12:03:27.0078/4/20250
XV0170452025-08-04T12:10:03.5070037-05:00OPENPV_D194118/4/2025 12:10:03.5078/4/20251
XV0170452025-08-04T12:50:58.5070037-05:00CLOSEDPV_D194138/4/2025 12:50:58.5078/4/20250
XV0170452025-08-04T20:50:58.5070037-05:00CLOSEDPV_D194158/4/2025 08:50:58.5078/4/20250

 

The ones in red are exact duplicates of each other.

 

What could be causing this, and is there a way to mitigate without using "Remove Duplicates" (the actual data set is nearly 1,000,000 rows each) ? The two queries come from different base tables, so creating an Index on RS_Samples for matching would not work.

 

I am on version 2.154.956.0 64-bit (May 2026)

 

Thanks,

David

 

  • Can you verify that there are no duplicates when using the TS-MS column. From the example data you provided it looks like midnight and 12pm are both showing as 12:00:00 in your text column. This could be what is causing the duplicates...

2 Replies

  • Can you verify that there are no duplicates when using the TS-MS column. From the example data you provided it looks like midnight and 12pm are both showing as 12:00:00 in your text column. This could be what is causing the duplicates...

    • dedelman_clng's avatar
      dedelman_clng
      Community Champion

      jgeddes - thank you so very much. I have been staring at this for days. Fixed the creation of the TS-MS column to use HH instead of hh in the format and the duplicates are gone.