MySQL基础巩固

select distinct university from user_profile;
-- distinct 去重

  

 

select device_id from user_profile limit 0,2
View Code
select device_id from user_profile WHERE id = 1 or id = 2;
-- 取出固定值的两种方式

 

select device_id as user_infos_example from user_profile limit 2;
--更新列名

6.请你从用户信息表中取出满足条件的数据,结果返回设备id和学校

 

select device_id,university from user_profile where university = '北京大学';
--取出满足条件的数据

7.现在运营想要针对24岁以上的用户开展分析,请你取出满足条件的设备ID、性别、年龄、学校

select
    device_id,gender,age,university
from
    user_profile where age > '24';

8. 题目:现在运营想要针对20岁及以上且23岁及以下的用户开展分析,请你取出满足条件的设备ID、性别、年龄。

 

select 
device_id, gender, age
from user_profile
where age between 20 and 23;

9. 题目:现在运营想要查看除复旦大学以外的所有用户明细,请你取出相应数据

 

select
    device_id,
    gender,
    age,
    university
from
    user_profile
where
    university != '复旦大学';

10. 题目:现在运营想要对用户的年龄分布开展分析,在分析时想要剔除没有获取到年龄的用户,请你取出所有年龄值不为空的用户的设备ID,性别,年龄,学校的信息

 

select
    device_id,
    gender,
    age,
    university
from
    user_profile
where
    age is not null ;

 

posted @ 2023-05-17 23:49  Icy_yayaya  阅读(37)  评论(0)    收藏  举报