当前位置:网站首页>SQL试题
SQL试题
2022-08-03 09:20:00 【嘻哈∠※】
考点1:in的用法
题目:现在运营想要找到学校为北大、复旦和山大的同学进行调研,请你取出相关数据。

select device_id,gender,age,university,gpa
from user_profile
where university in ("北京大学","复旦大学","山东大学")
考点2:or的用法
题目:现在运营想要找到学校为北大或GPA在3.7以上(不包括3.7)的用户进行调研,请你取出相关数据(使用OR实现)


select device_id,gender,age,university,gpa
from user_profile
where university = "北京大学" or gpa > 3.7
考点3:不为空
题目:现在运营想要对用户的年龄分布开展分析,在分析时想要剔除没有获取到年龄的用户,请你取出所有年龄值不为空的用户的设备ID,性别,年龄,学校的信息。

select device_id,gender,age,university
from user_profile
where
age !=""
# 第二种age is not null
考点4:不包含某一项
题目:现在运营想要查看除复旦大学以外的所有用户明细,请你取出相应数据

select device_id,gender,age,university
from user_profile
#where university !="复旦大学"
#where university not like "复旦大学"
where university not in ("复旦大学")
考点5:and和or
题目:现在运营想要找到gpa在3.5以上(不包括3.5)的山东大学用户 或 gpa在3.8以上(不包括3.8)的复旦大学同学进行用户调研,请你取出相应数据

select device_id,gender,age,university,gpa
from user_profile
where (gpa>3.5 and university="山东大学")
or (gpa>3.8 and university="复旦大学")
考点6:like模糊语句
题目:现在运营想查看所有大学中带有北京的用户的信息,请你取出相应数据。

select device_id,age,university
from user_profile
where university like ("%北京%")
#包含北京的 university like ("%北京%")
#以北京开头的 university like ("北京%")
# 以北京结尾的("%北京")
考点7:distinct去重唯一
题目:现在运营需要查看用户来自于哪些学校,请从用户信息表中取出学校的去重数据。

select distinct university from user_profile
考点8:最大值和降序(取第一行数据)
题目:运营想要知道复旦大学学生gpa最高值是多少,请你取出相应数据

法1:通过降序,然后取第一条
select gpa
from user_profile
where university = "复旦大学"
order by gpa DESC limit 1
法2:使用聚合函数取最大值
select max(gpa)
from user_profile
where university = "复旦大学"
边栏推荐
- LeetCode第三题(Longest Substring Without Repeating Characters)三部曲之二:编码实现
- STP生成树(端口状态+端口角色+收敛机制 )|||| STP优化技术( uplinkfast技术+Portfast技术+backbonefast技术 )详解
- System io statistics
- 软体按摩机器人驱动器的设计与仿真
- Unity编辑器扩展批量修改图片名称
- AUC的两种计算方式
- 系统io统计
- Chrome F12 keep before request information network
- STP生成树选举结果查看及验证
- LeetCode第三题(Longest Substring Without Repeating Characters)三部曲之二:编码实现
猜你喜欢
随机推荐
【LeetCode】101.对称二叉树
Redis和MySQL如何保持数据一致性
固件工程师到底是干什么?
SQL每日一练(牛客新题库)——第5天:高级查询
dflow入门2——Slices
浅聊缓存函数
Partition table (1)
STP和RSTP的BPDU报文中flag位 对比+分析
机器学习(公式推导与代码实现)--sklearn机器学习库
MySQL的分页你还在使劲的limit?
When deleting a folder, the error "Error ox80070091: The directory is not empty" is reported. How to solve it?
MySQL-DDL数据定义语言-约束
常见STP生成树调整命令
013-Binary tree
好用的插件
Automated test browser driver download version
Rabbit and Falcon are all covered, Go lang1.18 introductory and refined tutorial, from Bai Ding to Hongru, the whole platform (Sublime 4) Go lang development environment to build EP00
线程介绍与使用
QT中线程调用GUI主线程控件的问题
梯度消失和梯度爆炸









