Skip to content

SQL API failed - sum + case whenΒ #8309

@egisberto

Description

@egisberto

Failed SQL
SELECT sum(CASE WHEN indicator_nm IN ('[REPLACED]') THEN 1 ELSE 0 END) AS asdf FROM pregnants_view LIMIT 1001

Logical Plan

Version:
0.34.52

Additional context
I try to execute this simple query to SUM values and after this make a division by the total values. (percent of certain indicator_nm). I'm using Superset as dashboard creator and thia is the one way that I found to make the percentage works on Superset. (https://docs.preset.io/docs/using-metrics-and-calculated-columns)

The final query wold be:

SELECT (CAST(sum(CASE WHEN indicator_nm = 'odontoCare' THEN 1 ELSE 0 END) AS FLOAT) / CAST(count(1) AS FLOAT)) * 100

Metadata

Metadata

Assignees

Labels

questionThe issue is a question. Please use Stack Overflow for questions.tool:preset

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions