SQL – After group by filtering down to rows where column value = certain string

Advertisements

Not sure why this isn’t working.

When I run the query without HAVING segment ilike 'Enterprise' I get results (see screenshot) but when I add it back in the query returns nothing despite clearly containing instances where segment = ‘Enterprise’. I can’t find any instances online where having is used to filter for strings so I’m thinking this just isn’t possible. Could someone confirm if this is the case and if there is an alternative method if so? Thanks.

>Solution :

You can’t use HAVING to filter for strings, you can only use it to filter for numeric values. To filter for strings, you’ll need to use the WHERE clause.

Leave a ReplyCancel reply