The GROUP BY clause groups data from multiple record and returns one row for each group. On other hand, it reduces the number of rows in the result set. The GROUP BY clause must appear after the WHERE clauses.
To group the data from multiple record into one row for each group, use the following syntax:
tablename: The table name from which you want to fetch the records.
condition: To specify the conditions that must be fulfilled for the records to be selected.
GROUP BY: To sorts data set in descending order.
aggregate_function: It specifies the aggregate functions i.e. SUM, COUNT, MIN, MAX or AVG functions.
In the above example, we have fetched records from "tblCustomerLoan" table with
GROUP BY on "firstName". As you can see, the
GROUP BY clause returns sum of "workHover" values.
In the above example, we have grouped "firstName" and count repetitive "firstName" in the column "firstName" from "tblCustomerLoan" table. As you can see, the
GROUP BY clause returns count for each repetitive "firstName".
In the above example, we have grouped "banks" name and count repetitive "banks" name in the column "banks" from "tblbankdemataccountcharges" table with
INNER JOIN "tblbankheadquartersandaddress" table. As you can see, the
GROUP BY clause returns count for each repetitive "banks" name.