Grouping Data : Group : Select Clause SQL / MySQL


SQL / MySQL » Select Clause » Group »

 

Grouping Data



/* Create table */
Drop TABLE StudentExam;

CREATE TABLE StudentExam (
   StudentID  INT NOT NULL,
   Mark       INT,
   Comments   VARCHAR(255)
   
)TYPE = InnoDB;

/* Insert data */
INSERT INTO StudentExam (StudentID,Mark,CommentsVALUES (10,76,'Java');
INSERT INTO StudentExam (StudentID,Mark,CommentsVALUES (10,65,'C#');
INSERT INTO StudentExam (StudentID,Mark,CommentsVALUES (10,79,'JavaScript');

INSERT INTO StudentExam (StudentID,Mark,CommentsVALUES (11,66,'Java');
INSERT INTO StudentExam (StudentID,Mark,CommentsVALUES (11,85,'C#');
INSERT INTO StudentExam (StudentID,Mark,CommentsVALUES (11,69,'JavaScript');

Select * from StudentExam;

/* Real command */
SELECT StudentID, AVG(MarkAS AverageMark
FROM StudentExam
WHERE ExamID IN 5811 )
GROUP BY StudentID
HAVING AVG(Mark50 OR AVG(Mark70;

           
       



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

SQL / MySQL

 Navioo Select Clause
» Group