Skip to content

Instantly share code, notes, and snippets.

@SolomonHD
Created February 18, 2015 08:05
Show Gist options
  • Save SolomonHD/d53b106df6dbf9368a38 to your computer and use it in GitHub Desktop.
Save SolomonHD/d53b106df6dbf9368a38 to your computer and use it in GitHub Desktop.
SQL Statements
#1
SELECT * FROM authors WHERE email = "shakespeare@example.com"
#2
SELECT * FROM authors ORDER BY created_at DESC LIMIT 1;
#3
SELECT question_text, count(*) FROM questions GROUP BY question_type
#4
SELECT response_text, count(*) FROM responses GROUP BY response_text ORDER BY count(*) DESC WHERE question id= X
#5
SELECT email, title
FROM surveys LEFT JOIN authors
ON surveys.author_id = authors.id
#6
SELECT name FROM authors LEFT JOIN surveys ON surveys.author_id = authors.id WHERE surveys.author_id IS NULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment