今天小編給大家分享一下MySQL學(xué)生表怎么創(chuàng)建的相關(guān)知識(shí)點(diǎn),內(nèi)容詳細(xì),邏輯清晰,相信大部分人都還太了解這方面的知識(shí),所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來(lái)了解一下吧。
成都創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供池州網(wǎng)站建設(shè)、池州做網(wǎng)站、池州網(wǎng)站設(shè)計(jì)、池州網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、池州企業(yè)網(wǎng)站模板建站服務(wù),十多年池州做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。
題目:
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","計(jì)算機(jī)系","北京市海淀區(qū)"),
("201902","郭大俠","男","1986","中文系","北京市昌平區(qū)"),
("201903","張三","女","1990","中文系","湖南省永州市"),
("201904","李四","男","1990","英語(yǔ)系","遼寧市阜新市"),
("201905","王五","女","1991","英語(yǔ)系","福建省廈門市"),
("201906","王六","男","1988","計(jì)算機(jī)系","湖南省衡陽(yáng)市");
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 總計(jì)
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學(xué)生表怎么創(chuàng)建”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,小編每天都會(huì)為大家更新不同的知識(shí),如果還想學(xué)習(xí)更多的知識(shí),請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。