mysql 練習(xí)題收集

返回身份證號(hào)相同,但性別不同的信息


1464056596539971.png
select A.name,A.people_id from
(select name,people_id,count(distinct sex) as 'count' from people  group by name,people_id) as A  
where A.count= 2;

將查詢出的兩列數(shù)據(jù) 合并成一列 并去重。表明為union_1


1464057850931296.png
select nid from union_1
union
select mid from union_1

用mysql語(yǔ)句實(shí)現(xiàn) 右邊那樣的結(jié)果


SELECT a.ver,a.kid,a.mid  FROM top3 a 
inner join top3 b  on a.ver =b.ver and a.kid=b.kid and a.mid<=b.mid
group by a.ver,a.kid,a.mid having count(*)<=3
order by a.ver, a.kid desc, a.mid desc;

查詢兩門及兩門以上不及格同學(xué)的平均分


1464061334369148.png
select name,avg(score),sum(score<60)as gk from stu 
group by name having gk>=2;
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容