SQL语句练习-入门篇,Python面试40题

本文通过一系列SQL查询题目,涵盖了基础到进阶的查询技巧,如别名使用、条件过滤、范围查询、正则匹配、分组聚合等。同时,文章提及Python面试中的相关知识点,适合备考者提升SQL和Python能力。
摘要由CSDN通过智能技术生成

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&#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值