mardi 11 décembre 2018

why is this SQL CASE WHEN giving column cannot be resolved error

I am trying to run a very simple case when statement but I'm getting an error saying that the variable I'm trying to create cannot be resolved

SELECT userid, sum(end_time-start_time)/60 AS timespent_minutes, 
                    CASE WHEN webid = '324234' THEN 'CA'
                    ELSE 'Other' END AS storeloc
FROM time_spent_intervals
WHERE (ds = '2018-12-01')
GROUP BY userid, storeloc

I'm getting the following error

Error: SYNTAX_ERROR
line 6:38: Column 'storeloc' cannot be resolved

can someone tell me why I'm getting this error??

Aucun commentaire:

Enregistrer un commentaire