Skip to content

Instantly share code, notes, and snippets.

@firstfu
Created September 24, 2016 17:56
Show Gist options
  • Save firstfu/a163e27ad15b6c61542fa9c958b36b05 to your computer and use it in GitHub Desktop.
Save firstfu/a163e27ad15b6c61542fa9c958b36b05 to your computer and use it in GitHub Desktop.
##GroupBy
SELECT sup_id, SUM(price), avg(price) FROM coffees GROUP BY sup_id
##聚合函數後可加別名Alias(須空隔)
SELECT AVG(total) 平均 , SUM(total) 總和, COUNT(*), MAX(price) 最大價格, MIN(price) 最小價格 FROM coffees
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment