| | |
SQL COUNT Command
We can count the number of records in a table with different combinations.
Let us first count the total number of records in the table with this count
command.
SELECT count( * ) as total_record FROM student
This will display total records under the name total_record in the table student. Now we
can add some condition to this SQL to count the records with different
conditions. Let us find out the number of students in class Four in out
table.
We are using alias here to display the value under hading total_record
SELECT count( * ) as total_record FROM `student` WHERE class = 'four'
This will return the count of students in class four only. Here since we are
displaying only one count for a fixed class so we can use this way. We may
require to display total of each class in a table so here we have to use
GROUP BY clause to display totals of all the tables.
| |
| | Nagappan | 06-11-2009 |
|---|
| IT'S VERY NICE | | nayan | 02-04-2010 |
|---|
| hi thanks for giving information thanks again... | | sumit | 27-04-2010 |
|---|
| please tell me the query if i want to count the no. employees from a table emp_detail (and display it) and also need to see the different entries of a different table course_detail ? I need to see them on single web page together.. | | Rajan Arora | 25-06-2010 |
|---|
| Really simple and nice way to explain... Gr8 gng... Keep it Up ... | | ragavan | 11-07-2010 |
|---|
u r done a very good job.
i need the answer for how to get the totals of the three columns in the table. |
|
|
|
|
|