Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
dev:sql:statements:select:group_by [2010/07/03 22:21]
tdo
dev:sql:statements:select:group_by [2016/06/28 22:38] (current)
Line 3: Line 3:
 ====== Omnidex SQL: SELECT GROUP_BY Clause ====== ====== Omnidex SQL: SELECT GROUP_BY Clause ======
 {{page>:​sql_bar&​nofooter&​noeditbtn}} {{page>:​sql_bar&​nofooter&​noeditbtn}}
-^See Also:​^[[dev:​sql:​statements:​select:​home | SELECT statement ]]^[[dev:​sql:​statements:​select:​from | FROM clause]]^[[dev:​sql:​statements:​select:​where |WHERE clause ]]^[[dev:​sql:​statements:​select:​group_byGROUP BY clause]]^ ​+^See Also:​^[[dev:​sql:​statements:​select:​home | SELECT statement ]]^[[dev:​sql:​statements:​select:​from | FROM clause]]^[[dev:​sql:​statements:​select:​where |WHERE clause ]]^[[dev:​sql:​statements:​select:​order_byORDER BY clause]]^ ​
  
 ===== Description ===== ===== Description =====
- 
 ===== Syntax ===== ===== Syntax =====
 +<​code>​
 +  GROUP BY group_by_columns
 +      [ HAVING [ left_operand operator subquery ]
 +               [ left_operand IN (subquery) ] ]
 +</​code>​
  
-  Statement 
-  
-===== Discussion ===== 
  
-== arg1 ==+===== Examples =====
  
-== arg2 ==+Column Names From the Select List 
 +  select customer_no,​ sum(amount) from orders group by customer_no
  
-===== Examples =====+  select city, state, count(distinct company) from customers group by city, state 
 + 
 +Column Names Not in the Select List 
 +  select status, sum(amount) from orders group by customer_no,​ status 
 + 
 +  select count(company) from customers group by state 
 + 
 +  
 + 
 +Having 
 +  select customer_no,​ sum(amount) from orders  
 +     group by customer_no having customer_no ​1001;
  
-==== Simple ====+  select customer_no,​ sum(amount) from orders  
 +     group by customer_no having status !'​shipped';​
  
-==== 2nd example ====+  select status, sum(amount) from orders group by status having customer_no  
 +     in (select customer_no from customers where company='​systems'​);​
  
 {{page>:​bottom_add&​nofooter&​noeditbtn}} {{page>:​bottom_add&​nofooter&​noeditbtn}}
 
Back to top
dev/sql/statements/select/group_by.1278195663.txt.gz · Last modified: 2016/06/28 22:38 (external edit)