当前位置:网站首页>SQL exam questions
SQL exam questions
2022-08-03 09:33:00 【Hip Hop∠※】
目录
考点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:does not contain an item
题目:现在运营想要查看除复旦大学以外的所有用户明细,请你取出相应数据
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)of Shandong University
用户 或 gpa在3.8以上(不包括3.8)的复旦大学
Students conduct user research,请你取出相应数据
select device_id,gender,age,university,gpa
from user_profile
where (gpa>3.5 and university="山东大学")
or (gpa>3.8 and university="复旦大学")
考点6:like模糊语句
题目:Now the operation wants to view all the universitieswith Beijing
的用户的信息,请你取出相应数据.
select device_id,age,university
from user_profile
where university like ("%北京%")
#Including Beijing university like ("%北京%")
#以北京开头的 university like ("北京%")
# It ends with Beijing("%北京")
考点7:distinctGo heavy only
题目:现在运营需要查看用户来自于哪些学校,Please remove the school's from the user information sheet去重
数据.
select distinct university from user_profile
考点8:Maximum and descending order(取第一行数据)
题目:Operations want to know复旦大学
学生gpa最高值
是多少,请你取出相应数据
法1:by descending order,然后取第一条
select gpa
from user_profile
where university = "复旦大学"
order by gpa DESC limit 1
法2:使用聚合函数取最大值
select max(gpa)
from user_profile
where university = "复旦大学"
边栏推荐
猜你喜欢
随机推荐
多媒体数据处理实验3:图像特征提取与检索
Oracle 迁移至Mysql
js中最简单base64图片流实现自动下载
Go的Gin框架学习
mysql的union和union all
【LeetCode】622.设计循环队列
2022最新整理软件测试常见面试题附答案
【LeetCode】112.路径总和
LINGO 18.0 software installation package download and installation tutorial
ClickHouse查询语句详解
命令行加载特效 【cli-spinner.js】 实用教程
013-二叉树
Exception: Dataset not found.解决办法
selenium IDE的3种下载安装方式
10分钟带你入门chrome(谷歌)浏览器插件开发
【LeetCode】zj面试-把字符串转换成整数
自动化测试浏览器驱动下载版本对应关系
MySQL的主从复制
深度学习之 10 卷积神经网络2
【LeetCode】226.翻转二叉树