编辑代码

create database student;
use student;
create table student_info(
    ID int,
    xh varchar(255),
    xm varchar(255),
    xb varchar(255),
    csny varchar(255),
    nj int,
    xy varchar(255)
);

insert into student_info VALUES (1,  'J171001', '张三丰', '男', '2001年3月', 21, '信息工程');
insert into student_info VALUES (2,  'J171002', '李静', '女', '2001年2月', 21, '工商管理');
insert into student_info VALUES (3,  'J1711003', '张明', '男', '2001年3月', 21, '计算机科学与应用');
insert into student_info VALUES (4,  'J1721001', '王丽', '女', '2002年6月', 22, '轮机工程');
insert into student_info VALUES (5,  'J1721002', '李大成', '男', '2002年9月', 22, '机电工程');
insert into student_info VALUES (6,  'J1721002', '张自云', '女', '2000年4月', 22, '艺术学院');
insert into student_info VALUES (7,  'J1731003', '刘芳芳', '女', '2002年8月', 23, '材料学院');
insert into student_info VALUES (8,  'J1731003', '赵明明', '男', '2001年12月', 23, '智能工程学院');
insert into student_info VALUES (9,  'J1731003', '赵明', '男', '2004年11月', 21, '工程学院');

/*查询表中 年级为22,23级的学生*/
/*SELECT *  FROM student_info where nj = 22 or nj = 23 ;*/

/*查询 出生日期2002年纪学生*/
/*SELECT *  FROM student_info where csny like '2002%' ;*/

/*查询学院为计算机科学与应用的学生记录*/
SELECT *  FROM student_info where xy like '计算机科学与应用' ;

/*男生女生数量*/
SELECT xb,count(*) FROM student_info group by xb;

/*查询 学号为J1721001的学生记录*/
SELECT * FROM student_info where xh = 'J1721001';