Skip to content

Instantly share code, notes, and snippets.

@embayer
Last active June 21, 2016 11:08
Show Gist options
  • Save embayer/52394a07cb79d95ae74afebba2c2fa70 to your computer and use it in GitHub Desktop.
Save embayer/52394a07cb79d95ae74afebba2c2fa70 to your computer and use it in GitHub Desktop.
sql cheatsheet
-- find duplicated values
SELECT
address_line1, address_line2, zip, city, country, COUNT(*)
FROM
location
GROUP BY
address_line1, address_line2, zip, city, country
HAVING
COUNT(*) > 1;
-- show the average length of a column
SELECT
AVG(LENGTH(column1))
FROM table1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment