Skip to content

Instantly share code, notes, and snippets.

@milesstewart88
Last active December 18, 2015 22:59
Show Gist options
  • Save milesstewart88/5858597 to your computer and use it in GitHub Desktop.
Save milesstewart88/5858597 to your computer and use it in GitHub Desktop.
Using the HAVING keyword
/*
* When creating alias' and temp tables
* can't use where so use the
* HAVING keyword
*/
SELECT
CONCAT(bill_first_name, ' ', bill_last_name) AS full_name,
COUNT(CONCAT(bill_first_name, ' ', bill_last_name)) AS amount,
MAX(ordered_on) as date, email
HAVING
amount BETWEEN '25' AND '400'
AND
date BETWEEN '2013-07-17' AND '2013-07-21'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment