This link has been bookmarked by 22 people . It was first bookmarked on 31 Mar 2008, by Mats Svensson.
-
05 Sep 12
-
COUNT function returns the number of rows in a query.
-
SELECT COUNT(expression)
FROM tables
WHERE predicates; -
ield in the brackets is NOT NULL.
-
use the DISTINCT clause within the COUNT function.
-
-
04 Apr 12
-
24 Oct 11
-
A more efficient implementation of the same solution would be the following SQL statement:
SELECT COUNT(1) as "Number of employees"
FROM employees
WHERE salary > 55000; -
Now, the COUNT function does not need to retrieve all of the fields from the table (ie: employee_number, employee_name, and salary), but rather whenever the condition is met, it will retrieve the numeric value of 1. Thus, increasing the performance of the SQL statement.
-
-
28 Dec 10
-
06 Oct 10
-
COUNT(1)
-
-
01 Sep 10
-
25 Jan 10
-
05 Sep 08
-
09 Jun 08
-
29 Oct 07
-
01 Aug 07
-
06 Sep 06
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.