Skip to content

Instantly share code, notes, and snippets.

@yalab
Last active August 29, 2015 10:07
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 yalab/ebacaccf762f03061682 to your computer and use it in GitHub Desktop.
Save yalab/ebacaccf762f03061682 to your computer and use it in GitHub Desktop.
test=> SELECT sid, lid, COUNT(id) FROM attend GROUP BY sid, lid HAVING COUNT(id) > 1;
sid | lid | count
-----+---------+-------
336 | ACB0030 | 2
325 | ABF0030 | 2
(2 rows)
test=> SELECT id FROM attend WHERE sid = 336 AND lid = 'ACB0030';
id
-------
60959
60960
(2 rows)
test=> SELECT id FROM attend WHERE sid = 325 AND lid = 'ABF0030';
id
-------
75117
(1 row)
test=> SELECT version();
version
------------------------------------------------------------------------------------------------------
PostgreSQL 9.3.6 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2, 64-bit
(1 row)
test=> SELECT sid, lid, COUNT(id) FROM attend GROUP BY sid, lid HAVING COUNT(id) > 1;
sid | lid | count
-----+---------+-------
336 | ACB0030 | 2
325 | ABF0030 | 2
(2 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment