Request help in postgres sql on CASE statement

  • What Grafana version and what operating system are you using?
    v8.5.15

  • What are you trying to achieve?
    I am trying to get the CPU percentage on per session during the execution, and update the cpu percenge in low or mederate or high according to the average cpu usage percent .

  • How are you trying to achieve it?
    I am using case statement to update the cpu percent in any one column like low/moderate/high according to cpu usage percent.

  • What happened?
    Its getting updated in all three columns like low/moderate and high

  • What did you expect to happen?
    Cpu percent should update in either of the column according to the usage percent

  • Can you copy/paste the configuration(s) that you are having problems with?
    QUERY: (used case statement )
    ======
    AVG(CASE WHEN (cpu > 0 and cpu <= 50 ) THEN (cpu) END) AS
    low,
    AVG(CASE WHEN (cpu > 50 and cpu <= 70 ) THEN (cpu) END) AS
    moderate,
    AVG(CASE WHEN (cpu > 70 ) THEN (cpu) END) AS high,

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    Dint received errors but it gets updated in all three column which is not expected.

  • Did you follow any online instructions? If so, what is the URL? NO

Welcome,

You question is really not about grafana but postgres and you might get better traction asking this question in a postgres forum?

but that said what does the above mean?