当前位置:网站首页>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 = "复旦大学"
边栏推荐
- The display of the article list and the basics of creating articles and article details
- chrome F12 network 保留之前请求信息
- 合并两个有序链表
- SQL Daily Practice (Nioke New Question Bank) - Day 5: Advanced Query
- QT中线程调用GUI主线程控件的问题
- 固件工程师到底是干什么?
- MySQL-DDL数据定义语言-约束
- 015-平衡二叉树(一)
- Batch PNG format can be converted to JPG format
- MySQL 主从切换步骤
猜你喜欢
删除文件夹时,报错“错误ox80070091:目录不是空的”,该如何解决?
10分钟带你入门chrome(谷歌)浏览器插件开发
浅聊缓存函数
别人都不知道的“好用”网站,让你的效率飞快
Path Prefixes (倍增!树上の二分)
Flink Yarn Per Job - 提交应用
LeetCode第三题(Longest Substring Without Repeating Characters)三部曲之二:编码实现
【LeetCode】226.翻转二叉树
【无标题】
"Easy to use" websites that others don't know, make you more efficient
随机推荐
手把手教你如何自制目标检测框架(从理论到实现)
Automated test browser driver download version
Add Modulo 10 (规律循环节,代码实现细节)
MySQL-存储过程-函数-
LeetCode第三题(Longest Substring Without Repeating Characters)三部曲之二:编码实现
dflow入门1——HelloWorld!
Batch PNG format can be converted to JPG format
Network LSTM both short-term and long-term memory
Cartesi 2022 年 7 月回顾
Unity编辑器扩展批量修改图片名称
dflow入门4——recurse&reuse&conditional
【LeetCode】101. Symmetric Binary Tree
PostgreSQL的架构
多线程下的单例模式
php中去重二维数组
二叉查找树的综合应用
子查询和关联查询的区别
bihashSummary
合并两个有序链表
oracle ASM磁盘空间的查看