Derived column in influxql

Greetings

Can influxql or flux do something like the following derived column matching ?

select * ,
case when ( [System Model] = 'Power Egde R640' and [bios ver] = '2.21.2' ) then 1 
  when ( [System Model] = 'Power Egde R641' and [bios ver] = '2.21.2' ) then 1
else 0 end as matching
from (
		select 'Power Egde R640' as [System Model], 'OK' as [Power State], 'OK' As [Global Status], '8.6 weeks' as Uptime, '3.21.2' as [bios ver] union
		select 'Power Egde R641' as 'System Model', 'NOK' as 'Power State', 'NOK' As 'Global Status', '21.8 hours' as Uptime, '2.21.2' as 'bios ver'
	 ) a

Thanks!

I think these are two ok examples

InfluxQL Example:

sqlCopy code

SELECT *,
    CASE
        WHEN "System Model" = 'Power Egde R640' AND "bios ver" = '2.21.2' THEN 1
        WHEN "System Model" = 'Power Egde R641' AND "bios ver" = '2.21.2' THEN 1
        ELSE 0
    END AS matching
FROM (
    SELECT 'Power Egde R640' AS "System Model", 'OK' AS "Power State", 'OK' AS "Global Status", '8.6 weeks' AS Uptime, '3.21.2' AS "bios ver"
    UNION
    SELECT 'Power Egde R641' AS "System Model", 'NOK' AS "Power State", 'NOK' AS "Global Status", '21.8 hours' AS Uptime, '2.21.2' AS "bios ver"
) a

Flux Example:

import "csv"

data = "
,System Model,Power State,Global Status,Uptime,bios ver
1,Power Egde R640,OK,OK,8.6 weeks,3.21.2
2,Power Egde R641,NOK,NOK,21.8 hours,2.21.2
"

csv.from(csv: data)
    |> map(fn: (r) => ({
        r with
        matching: if r["System Model"] == "Power Egde R640" and r["bios ver"] == "2.21.2" then 1
                    else if r["System Model"] == "Power Egde R641" and r["bios ver"] == "2.21.2" then 1
                    else 0
    }))
1 Like

Thanks so much for your assistance