Skip to content

Instantly share code, notes, and snippets.

@rnewman
Created April 4, 2012 20:46
Show Gist options
  • Save rnewman/2305471 to your computer and use it in GitHub Desktop.
Save rnewman/2305471 to your computer and use it in GitHub Desktop.
Start of a query
PSEUDOCODE! Need to join the subquery to get the values available for the update.
UPDATE history SET visits = total
modified = latest
deleted = (modified <> latest)
WHERE uri IN (
SELECT uri, count(uri), SUM(visits) AS total, MAX(modified) AS latest
GROUP BY uri
HAVING count(uri) > 1
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment