~skinny.moey/drizzle/inno_replication_order

« back to all changes in this revision

Viewing changes to docs/count.rst

  • Committer: Lee Bieber
  • Date: 2011-01-18 20:05:06 UTC
  • mfrom: (2094.1.6 build)
  • Revision ID: kalebral@gmail.com-20110118200506-r1v72y174j5x7j0i
Merge Brian - fix processlist test, was failing under lcov
Merge Marisa - fix bug 684803: Need to update Drizzledump documentation with migration conversions / caveats
Merge Marisa - fix bug #686641: Need to document removal of multi-table update/delete from Drizzle
Merge Monty - fix bug 567387: quotes now appearing around module name and author in data_dicionary view
Merge Monty - fix bug 658752: Incorrect datadir value being stored
Merge Andrew - fix bug 680872: max-connect-errors appears to be unused 
Merge Stewart - Haildb updates, ANALYZE table as well as improved index statistics

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
COUNT
 
2
-----
 
3
 
 
4
Take the following "Nodes" table, where 'nodes' are user-contributed content:
 
5
 
 
6
+--------+-------------------+------------+----------------+-------------------+
 
7
|NodeID  |ContributionDate   |NodeSize    |NodePopularity  |UserName           |
 
8
+--------+-------------------+------------+----------------+-------------------+
 
9
|1       |12/22/2010         |160         |2               |Smith              |
 
10
+--------+-------------------+------------+----------------+-------------------+
 
11
|2       |08/10/2010         |190         |2               |Johnson            |
 
12
+--------+-------------------+------------+----------------+-------------------+
 
13
|3       |07/13/2010         |500         |5               |Baldwin            |
 
14
+--------+-------------------+------------+----------------+-------------------+
 
15
|4       |07/15/2010         |420         |2               |Smith              |
 
16
+--------+-------------------+------------+----------------+-------------------+
 
17
|5       |12/22/2010         |1000        |4               |Wood               |
 
18
+--------+-------------------+------------+----------------+-------------------+
 
19
|6       |10/2/2010          |820         |4               |Smith              |
 
20
+--------+-------------------+------------+----------------+-------------------+
 
21
 
 
22
The SQL COUNT function returns the number of rows in a table satisfying the criteria specified in the WHERE clause. If we want to count how many orders has made a customer with CustomerName of Smith, we will use the following SQL COUNT expression: ::
 
23
 
 
24
        SELECT COUNT * FROM Nodes
 
25
        WHERE UserName = "Smith";
 
26
 
 
27
In the above statement, the COUNT keyword returns the number 3, because the user Smith has 3 total nodes.
 
28
 
 
29
If you don’t specify a WHERE clause when using the COUNT keyword, your statement will simply return the total number of rows in the table, which would be 6 in this example: ::
 
30
 
 
31
        SELECT COUNT * FROM Nodes;