sql-metadata icon indicating copy to clipboard operation
sql-metadata copied to clipboard

Does not find columns inside 'SUM-CASE-WHEN' pattern

Open staskikotx opened this issue 4 months ago • 0 comments

Take this query:

SELECT CAST(SUM(CASE WHEN segment = 'Premium' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) AS premiumpercentage FROM gasstations WHERE country = 'SVK'

The output is:

tables: ['gasstations']
columns: ['country']

Column 'segment' is missing.

staskikotx avatar Aug 21 '25 13:08 staskikotx