日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

SQL10 用where过滤空值练习

發布時間:2023/12/4 数据库 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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

select device_id,gender,age,university from user_profile where age 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过滤空值练习的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。