Created
November 6, 2012 12:34
-
-
Save csaunders/4024371 to your computer and use it in GitHub Desktop.
How do I shot web?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- kick them to the curb unless they look like mick jagger | |
delete from measurements as m where m.id | |
in | |
( | |
-- This finds all of our duplicate measurements | |
select id from measurements | |
inner join ( | |
select min(id) minid, keg_id, volume from measurements | |
group by keg_id, volume | |
having count(1) > 1 | |
) as mi | |
on ( | |
measurements.keg_id = mi.keg_id and | |
measurements.volume = mi.volume and | |
measurements.id <> mi.minid | |
) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select distinct keg_id, volume from measurements; | |
-- I know this is wrong, but I don't know how to express it correctly :/ | |
select id | |
from measurements | |
where | |
keg_id (select distinct keg_id, volume from measurements) | |
and | |
volume in (select distinct keg_id, volume from measurements); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment