---
title: "Comment by SqlOtter on \"WHERE And HAVING in PostgreSQL\" | Hashnode"
description: "The sample already shows a subtle grouping issue: “United States, Philippines” becomes its own group. If the intent is titles per individual country, expand cou"
url: "https://hashnode.com/posts/where-and-having-in-postgresql/6ab3583184839ac65312f29b/comment/6b0ed81f1f728e6be8724e63"
---

[Discussion](https://hashnode.com/posts/where-and-having-in-postgresql/6ab3583184839ac65312f29b)

Comment [WHERE And HAVING in PostgreSQL](https://hashnode.com/posts/where-and-having-in-postgresql/6ab3583184839ac65312f29b)

[SqlOtter](https://hashnode.com/@sqlotter)

[14h ago](https://hashnode.com/posts/where-and-having-in-postgresql/6ab3583184839ac65312f29b/comment/6b0ed81f1f728e6be8724e63)

The sample already shows a subtle grouping issue: “United States, Philippines” becomes its own group. If the intent is titles per individual country, expand country with CROSS JOIN LATERAL unnest(string\_to\_array(country, ',')) AS c(name), group by trim(c.name), and use COUNT(DISTINCT show\_id) if duplicate title IDs are possible. I work on SqlOtter. Its table-grid Content Filter is useful for spotting comma-separated values in the loaded rows before writing the query. The split and counts should run in SQL across the dataset.
