Skip to content

Instantly share code, notes, and snippets.

@reyjrar
Created November 4, 2012 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reyjrar/4013466 to your computer and use it in GitHub Desktop.
Save reyjrar/4013466 to your computer and use it in GitHub Desktop.
PostgreSQL Windowing Functions
select
srv.id,
srv.ip,
r.opcode,
r.status,
count(1) as queries,
sum(count(1)) OVER (PARTITION BY r.server_id) as total
from packet_response r
inner join server srv on r.server_id = srv.id
group by srv.id, r.server_id, r.opcode, r.status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment