Hello,
I have a problem with my Query :
SELECT (SELECT UTC_DATE() AS time, SUM(res1+res2+res3) AS A from (SELECT SUM(CASE WHEN number1 = 1 THEN 1 ELSE 0 END) AS res1,SUM(CASE WHEN number2 = 1 THEN 1 ELSE 0 END) AS res2, SUM(CASE WHEN number3 = 1 THEN 1 ELSE 0 END) AS res3 from artefact) AS RES)
I want to use the pie chart panel.
I have the message “Operand should contain 1 column(s)” and I’m stuck I don’t know what to do anymore.
Can you help me?
Thank you very much !
Can you post it for other people?
Yep, the solution is here :
I have to use a UNIX_TIMESTAMP and for each SUM I have to use “+”.
in my database I have three columns with 1, 2 and 3, and I want to know the total number of 1 in each column.
So the good query is :
SELECT UNIX_TIMESTAMP(NOW()) as time_sec,
SUM(CASE WHEN number1 = 1 THEN 1 ELSE 0 END) + SUM(CASE WHEN number2 = 1 THEN 1 ELSE 0 END) + SUM(CASE WHEN number3 = 1 THEN 1 ELSE 0 END) as ‘DELIVERY’,
SUM(CASE WHEN number1 = 2 THEN 1 ELSE 0 END) + SUM(CASE WHEN number2 = 2 THEN 1 ELSE 0 END) + SUM(CASE WHEN number3 = 2 THEN 1 ELSE 0 END) as ‘GOOD’,
SUM(CASE WHEN number1 = 3 THEN 1 ELSE 0 END) + SUM(CASE WHEN number2 = 3 THEN 1 ELSE 0 END) + SUM(CASE WHEN number3 = 3 THEN 1 ELSE 0 END) as ‘FAILED’
FROM artefact ;