COUNT

Returns the count of all values respecting the parameters given in the expression.

Syntax:

SELECT COUNT([DISTINCT] column [WHERE filtercolumn=value_to_test OR 
filtercolumn=another_value_to_test]) FROM table

Examples:

/* returns the number of distinct id's from the table transactions */ 
SELECT COUNT(DISTINCT id) FROM transactions

/* returns the number of distinct ids in column one and the number of distinct ids where the column chain=2
please note that this expression can be used in the datamodeler by simply typing the WHERE clause after
the columnname. */

SELECT COUNT(DISTINCT id) AS distinctids, COUNT(DISTINCT id WHERE chain=2) AS distinctidchain2
FROM transactions
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.