SQL10 用where过滤空值练习
生活随笔
收集整理的這篇文章主要介紹了
SQL10 用where过滤空值练习
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
描述
題目:現在運營想要對用戶的年齡分布開展分析,在分析時想要剔除沒有獲取到年齡的用戶,請你取出所有年齡值不為空的用戶明細數據。
示例:user_profile
根據輸入,你的 查詢應返回以下結果:
示例1
輸入:
drop table if exists user_profile; CREATE TABLE `user_profile` ( `id` int NOT NULL, `device_id` int NOT NULL, `gender` varchar(14) NOT NULL, `age` int , `university` varchar(32) NOT NULL, `province` varchar(32) NOT NULL); INSERT INTO user_profile VALUES(1,2138,'male',21,'北京大學','BeiJing'); INSERT INTO user_profile VALUES(2,3214,'male',null,'復旦大學','Shanghai'); INSERT INTO user_profile VALUES(3,6543,'female',20,'北京大學','BeiJing'); INSERT INTO user_profile VALUES(4,2315,'female',23,'浙江大學','ZheJiang'); INSERT INTO user_profile VALUES(5,5432,'male',25,'山東大學','Shandong');輸出:
2138|male|21|北京大學 6543|female|20|北京大學 2315|female|23|浙江大學 5432|male|25|山東大學AC代碼
判斷某列不為空:
1、 is not null
2、 not…is null
select device_id,gender,age,university from user_profile where not age is null;3、where age
select device_id,gender,age,university from user_profile where age;總結
以上是生活随笔為你收集整理的SQL10 用where过滤空值练习的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iPhone苹果手机键盘如何设置更加好用
- 下一篇: SQL15 查看学校名称中含北京的用户(