Databases| SQL| MySQL| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
SQL Max Count 
 

SQL Max Count is used to return the maximum records value of the specified column in a table.

 

SQL Max Count

                         

SQL Max Count is used to return the maximum records value of the specified column in a table.

Understand with Example

The Tutorial illiustrate an example from 'SQL Max Count'. To elaborate example we create a table 'Stu'. The create table create a table 'Stu' with required fieldnames and datatypes respectively.

 

 

 

 

Create table Stu

Create Table Stu(Id int,Name Varchar(15),Marks int);

Insert values into Stu

The insert into is used to add the records or rows into table 'Stu'.

Insert Into Stu values(1,'Ajay',89);
Insert Into Stu values(2,'Bhanu',67);
Insert Into Stu values(4,'Rakesh',67);
Insert Into Stu values(5,'Santosh',90);
Insert Into Stu values(3,'Komal',78);
Insert Into Stu values(1,'Ajay',45);
Insert Into Stu values(2,'Bhanu',67);
Insert Into Stu values(4,'Rakesh',87);
Insert Into Stu values(5,'Santosh',40);
Insert Into Stu values(3,'Komal',71);

Stu Table

+------+---------+-------+
| Id   | Name    | Marks |
+------+---------+-------+
| 1    | Ajay    | 89    |
| 2    | Bhanu   | 67    |
| 4    | Rakesh  | 67    |
| 5    | Santosh | 90    |
| 3    | Komal   | 78    |
| 1    | Ajay    | 45    |
| 2    | Bhanu   | 67    |
| 4    | Rakesh  | 87    |
| 5    | Santosh | 40    |
| 3    | Komal   | 71    |
+------+---------+-------+

Query for Max Count

The Query given below is used to sort the records by id and returns the maximum value of the marks from table 'stu'.

select id, name ,max(marks) from stu  group by id;

 Result

+------+---------+------------+
| id   | name    | max(marks) |
+------+---------+------------+
| 1    | Ajay    | 89         |
| 2    | Bhanu   | 67         |
| 3    | Komal   | 78         |
| 4    | Rakesh  | 87         |
| 5    | Santosh | 90         |
+------+---------+------------+

                         

» View all related tutorials
Related Tags: sql mysql c query rest table select io return tab show if condition ie record where records ci ws sh

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.