您好,登錄后才能下訂單哦!
今天小編給大家分享一下mysql學生表怎么創建的相關知識點,內容詳細,邏輯清晰,相信大部分人都還太了解這方面的知識,所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來了解一下吧。
題目:
create table student (
id varchar(20),
name varchar(20),
gender char(1),
birth varchar(20),
department varchar(20),
address varchar(20)
) charset = utf8;
insert into student values
("201901","張大佬","男","1985","計算機系","北京市海淀區"),
("201902","郭大俠","男","1986","中文系","北京市昌平區"),
("201903","張三","女","1990","中文系","湖南省永州市"),
("201904","李四","男","1990","英語系","遼寧市阜新市"),
("201905","王五","女","1991","英語系","福建省廈門市"),
("201906","王六","男","1988","計算機系","湖南省衡陽市");
select
department 院系,
case gender when "男" then 1 else 0 end 男,
case gender when "女" then 1 else 0 end 女
from student;
select
院系,
sum(男) 男,
sum(女) 女,
sum(男) + sum(女) as 總計
from
(
select department 院系,
case gender when "男" then 1 else 0 end 男,
case gender when "女" then 1 else 0 end 女
from student
) a
group by 院系;
?? ??
以上就是“mysql學生表怎么創建”這篇文章的所有內容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,小編每天都會為大家更新不同的知識,如果還想學習更多的知識,請關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。