Skip to content

Instantly share code, notes, and snippets.

@priyankakundu
Forked from tejpaldev/Group by single column
Created March 22, 2022 11:19
Show Gist options
  • Save priyankakundu/e297fe4fb8745c61d7355f4092b804e8 to your computer and use it in GitHub Desktop.
Save priyankakundu/e297fe4fb8745c61d7355f4092b804e8 to your computer and use it in GitHub Desktop.
select f.*,
count(*) over (
partition by title, uk_release_date
) ct
from films f;
select *
from (
select f.*,
count(*) over (
partition by title, uk_release_date
) ct
from films f
)
where ct > 1
Or you could use the with clause:
with film_counts as (
select f.*, count(*) over (partition by title, uk_release_date) ct
from films f
)
select *
from film_counts
where ct > 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment