select device_id from user_profile
limit 0,2
SQL5 将查询后的列重新命名
- 题目:现在你需要查看前2个用户明细设备ID数据,并将列名改为 ‘user_infos_example’,,请你从用户信息表取出相应结果。
select device_id as user_infos_example
from user_profile
limit 2
as 别名可省略
SQL6 查找学校是北大的学生信息
-
题目:现在运营想要筛选出所有北京大学的学生进行用户调研,请你从用户信息表中取出满足条件的数据,结果返回设备id和学校。
Select device_id ,university from user_profile
where university=“北京大学”
SQL7 查找年龄大于24岁的用户信息
-
题目:现在运营想要针对24岁以上的用户开展分析,请你取出满足条件的设备ID、性别、年龄、学校。
select device_id,gender,age,university from user_profile
where age>24
SQL8 查找某个年龄段的用户信息
- 题目:现在运营想要针对20岁及以上且23岁及以下的用户开展分析,请你取出满足条件的设备ID、性别、年龄。
select device_id,gender,age from user_profile
where age BETWEEN 20 and 23
#where age >=20 and age <=23
between and 是闭区间注意
SQL9 查找除复旦大学的用户信息
题目:现在运营想要查看除复旦大学以外的所有用户明细,请你取出相应数据
select device_id,gender,age,university from user_profile
#where university <> “复旦大学”
#where university != “复旦大学”
#where university not like “复旦大学”
where university not in ( “复旦大学”)
SQL10 用where过滤空值练习
-
题目:现在运营想要对用户的年龄分布开展分析,在分析时想要剔除没有获取到年龄的用户,请你取出所有年龄值不为空的用户的设备ID,性别,年龄,学校的信息。
select device_id ,gender,age,university from user_profile
#where age not like" null"
#where age not in (" null")
#where age!=" null"
where age<>" null"
SQL11 高级操作符练习(1)
-
题目:现在运营想要找到男性且GPA在3.5以上(不包括3.5)的用户进行调研,请你取出相关数据。
select device_id,gender,age,university,gpa from user_profile
where gender&#