Javatpoint Logo
Javatpoint Logo

SQLite GROUP BY Clause

The SQLite GROUP BY clause is used with SELECT statement to collaborate the same identical elements into groups.

The GROUP BY clause is used with WHERE clause in SELECT statement and precedes the ORDER BY clause.

Syntax:

Let's take an example to demonstrate the GROUP BY clause. We have a table named "STUDENT", having the following data:

Sqlite Group by clause 1

Use the GROUP BY query to know the total amount of FEES of each student:

Output:

Sqlite Group by clause 2

Now, create some more records in "STUDENT" table using the following INSERT statement:

Sqlite Group by clause 3

The new updated table has the inserted entries. Now, use the same GROUP BY statement to group-by all the records using NAME column:

Output:

Sqlite Group by clause 4

You can use ORDER BY clause along with GROUP BY to arrange the data in ascending or descending order.

Output:

Sqlite Group by clause 5




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA