how to select the min value using having key word

Posted by LOVE_KING on Stack Overflow See other posts from Stack Overflow or by LOVE_KING
Published on 2010-12-27T07:38:07Z Indexed on 2010/12/27 7:54 UTC
Read the original article Hit count: 392

Filed under:
|
|
|
|

I have created the table stu_dep_det

CREATE TABLE  `stu_dept_cs` (
  `s_d_id` int(10) unsigned NOT NULL auto_increment,
  `stu_name` varchar(15) , `gender` varchar(15) , `address` varchar(15),`reg_no` int(10) ,
  `ex_no` varchar(10) ,
  `mark1` varchar(10) ,
  `mark2` varchar(15) ,
  `mark3` varchar(15) ,
  `total` varchar(15) ,
  `avg` double(2,0),
  PRIMARY KEY  (`s_d_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC AUTO_INCREMENT=8 ;

then Inserted the values

INSERT INTO `stu_dept_cs` (`s_d_id`, `stu_name`, `gender`, `address`, `reg_no`, `ex_no`, `mark1`, `mark2`, `mark3`, `total`, `avg`) VALUES
(1, 'alex', 'm', 'chennai', 5001, 's1', '70', '90', '95', '255', 85),
(2, 'peter', 'm', 'chennai', 5002, 's1', '80', '70', '90', '240', 80),
(6, 'parv', 'f', 'mumbai', 5003, 's1', '88', '60', '80', '228', 76),
(7, 'basu', 'm', 'kolkatta', 5004, 's1', '85', '95', '56', '236', 79);

I want to select the min(avg) using having keyword and I have used the following sql statement

SELECT * FROM stu_dept_cs s  having  min(avg)

Is it correct or not plz write the correct ans....

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql