Hello community,
im struggling with a basic operation for counting the amount of values on a given column aiming to get the total value, however the result by using COUNT or SUM return weird data I don't understand the logic behind it.
Basically, I want to get the amount of repetitions of value "Compliance" I have for column 'response time sla'. The example below shows the correct number (i.e. "3") but instead of getting the result in a single cell, I got it as many rows the table has (i.e. "9"). This is the SQL im using:
SELECT
(SELECT COUNT(TT3.'response time sla') FROM T3 AS TT3 WHERE TT3.'response time sla' = "Compliance") AS '[KPI-DBE.3]',
(SELECT COUNT(TT3.'response time sla') FROM T3 AS TT3) AS '[KPI-DBE.3 TOTAL]',
FROM T3 AS TT3


However, when im adding a new line to the SQL to get the SUM of all values on that column (by using "SUM" as an alternative to "COUNT") I got this:


What should be the right sentence to use to get just "3" or "9" for above queries?
In addition, taking advantage of the thread, let me ask 2 basic questions about SQL:
1. How can I add a comment on the SQL box to define some instructions about the purpose of the query so reader can understand what it does? I was not able to find any reference on the documentation.
2. How can I create an int or chat variable and allocate some calculation so I can use the variable along the SQL instead of copy+pasting all the time whole calculation sentence?
Thanks very much in advance for your support!