Home > Database > SQL Group By Statement

SQL Group By Statement

September 10, 2013 Leave a comment Go to comments

Group by statement digunakan dengan select statement untuk  pengelompokan / grup berdasarkan kolom dan umumnya digunakan bersama dengan fungsi agregat.

Syntax :

SELECT column_name, aggregate_function ( column_name ) FROM table_name WHERE conditions GROUP BY column_name 

Berikut ini contoh group by statement :
Table Employee :

Table Employee

Table Employee

Group by statement :

SELECT department, sum(salary) as total_salary FROM `employee` GROUP BY department

Result :



Semoga bermanfaat.


  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: