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

MySQL2

多媒体数据处理实验3:图像特征提取与检索

dflow入门3——dpdispatcher插件

STP和RSTP的BPDU报文中flag位 对比+分析

Flink Yarn Per Job - Submit application

MySQL 免安装版的下载与配置教程

110 MySQL interview questions and answers (continuous updates)

Machine learning (formula derivation and code implementation)--sklearn machine learning library

播放量暴涨2000w+,单日狂揽24w粉,内卷的搞笑赛道还有机会

RSTP(端口角色+端口状态+工作机制)|||| 交换机接口分析
随机推荐
【LeetCode】226. Flip the binary tree
长短期记忆网络 LSTM
110道 MySQL面试题及答案 (持续更新)
MySQL的主从复制
QImage的指针问题
Exception: Dataset not found. Solution
Unity关于编辑器扩展自定义标签,方便扩展Inspector
Path Prefixes (倍增!树上の二分)
Flink Yarn Per Job - 启动AM
selenium IDE的3种下载安装方式
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
子查询和关联查询的区别
STP生成树(端口状态+端口角色+收敛机制 )|||| STP优化技术( uplinkfast技术+Portfast技术+backbonefast技术 )详解
Partition table (1)
pytorch one-hot tips
dflow部署简记
System io statistics
Redis的基础与django使用redis
oracle中的rownum函数
LeetCode第三题(Longest Substring Without Repeating Characters)三部曲之二:编码实现