当前位置:网站首页>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 = "复旦大学"
边栏推荐
猜你喜欢

cmd(命令行)操作或连接mysql数据库,以及创建数据库与表

MySQL_关于JSON数据的查询

响应式布局经典范例——巨幅背景大标题

MySQL-存储过程-函数-

Ultra-detailed Asp.net uses SSL two-way authentication, one article is enough

二叉查找树的综合应用

cnpm安装步骤

English Grammar - Adverbial Clauses

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

SQL试题
随机推荐
SQL每日一练(牛客新题库)——第5天:高级查询
oracle中的rownum函数
长短期记忆网络 LSTM
array of function pointers
【LeetCode】zj面试-把字符串转换成整数
超详细的Asp.net使用SSL双向认证,一篇就够了
力扣递归训练
milvus
Redis集群概念与搭建
Redis和MySQL如何保持数据一致性
What exactly does a firmware engineer do?
What are pseudo-classes and pseudo-elements?The difference between pseudo-classes and pseudo-elements
Partition table (1)
多媒体数据处理实验2:PCA
播放量暴涨2000w+,单日狂揽24w粉,内卷的搞笑赛道还有机会
MYSQL 修改时区的几种方法
使用 Scrapy 框架对重复的 url 无法获取数据,dont_filter=True
【LeetCode】101.对称二叉树
MySQL-DDL数据定义语言-约束
机器学习(公式推导与代码实现)--sklearn机器学习库