question

Julio R avatar image
0 Likes"
Julio R asked Julio R commented

Get maximum value thorough a calculated table

Hello,

I want to use the standard Output by hour by type dashboard to get also a table with the maximum value by Type.

To do this, I installed the Statistic and created a calculated table listening to the "Output By Hour By Type Collector" statistic collector that was created when I installed the Statistic.

What I need is the same table but that only display one row with the highest throughput value for each Type.

Then, I tried to use the Query builder interface, but I was not able to do it so I tried to modify the Query manually, and I dont undestand what Im doing wrong.

Is there an wasier way to achieve this or what am I doing wrong in my query?

Here is the SQL:

SELECT

Type AS [Partition 1]

, Time AS [Metric 1]

, Type AS [Metric 2]

, Throughput AS [Metric 3]


FROM [Output By Hour By Type Collector]

WHERE [Metric 3] = (SELECT MAX([Metric 3]) FROM [Output By Hour By Type Collector])

ORDER BY [Partition 1] ASC



And here is the example model:

Ejemplo tabla con máximos (Calculated table).fsm

FlexSim 23.0.5
sqlcalculated table
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Julio R commented

I can't say why your syntax is not working. I did find a working alternative using JOIN though.

  1. SELECT a.Time, a.Type, b.Max FROM [Output By Hour By Type Collector] AS a
  2. INNER JOIN (
  3.     SELECT Type, MAX(Throughput) AS Max
  4.     FROM [Output By Hour By Type Collector]
  5.     GROUP BY Type) AS b
  6. ON a.Throughput == b.Max
  7. ORDER BY Type ASC

Taken from here (top answer):
https://stackoverflow.com/questions/7745609/sql-select-only-rows-with-max-value-on-a-column

If the max value appears more than once this will return all rows with that value.

ejemplo-tabla-con-maximos-calculated-table_1.fsm


· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.