Coginiti menu Coginiti menu

SQL Sum

The SUM function in SQL is used to calculate the total values in a specific column of a table.

The basic syntax is:

SELECT
  SUM(column_name)
FROM
  table_name;

To exemplify how to use the SUM SQL, suppose you have a bookshop table with a price column. The total amount for all books can be calculated with the following SQL query:

SELECT
  SUM(price)
FROM
  bookshop;

If you want to sum only the Classic books, you could use a WHERE clause in a statement like this:

SELECT
  SUM(price)
FROM
  bookshop
WHERE
  genre = 'Classic';

In each of these examples, the SUM SQL function is used to calculate the totality of the values in a specific column of a table. The query’s result is a single value representing the sum of all the values in the column.

SQL SUM in Coginiti

Coginiti allows you to apply the aggregation functionality to any column by dragging and dropping the values you want to sum.

A screenshot showing the aggregation functions in the Coginiti Grid.

Here’s an example of how you can sum rows in Coginiti Grid:

  1. Open the Grid View
  2. Click “Columns’”
  3. Drag and drop the values you want to sum.

Note that when you drag and drop a column to “Values,” it will come with the last aggregation function used. Click on it to change and scroll to find the aggregate function you want.
A GIF showing how to select an aggregation function in the Coginiti Grid.