没有合适的资源?快使用搜索试试~ 我知道了~
大数据面试题SQL20道.docx
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 100 浏览量
2024-01-17
11:28:48
上传
评论
收藏 196KB DOCX 举报
温馨提示
试读
20页
大数据面试题SQL20道.docx
资源推荐
资源详情
资源评论
大数据 SQL 面试题
1. SQL 试题一
使用 SQL 查询 a,b 表中不相交的数据集。
a 表:
id
name
1
zhangsan
2
lisi
3
wangwu
4
maliu
5
tianqi
b 表:
id
name
1
zhangsan
2
lisi
3
wangwu
6
zhaoqi
7
gaoba
数据附件
a.txt
b.txt
create table a(id int ,name string) row format delimited fields
terminated by '\t';
create table b(id int ,name string) row format delimited fields
terminated by '\t';
select b.id,b.name from a full join b on a.id = b.id where a.id is
null
union
select a.id,a.name from a full join b on a.id = b.id where b.id is
null
2. SQL 试题二
使用 SQL 根据表 A,表 B 计算出表 C:
表 A
date
v1
2019/1/1
74
2019/1/2
54
2019/1/3
19
2019/1/6
84
2019/1/7
2
2019/1/8
78
2019/1/9
19
2019/1/10
95
表 B
date
V2
2019/1/1
13
2019/1/2
3
2019/1/3
29
2019/1/4
81
2019/1/5
37
2019/1/8
56
2019/1/9
53
2019/1/10
50
表 C
date
V1
V2
2019/1/1
74
13
2019/1/2
54
3
2019/1/3
19
29
2019/1/4
0
81
2019/1/5
0
37
2019/1/6
84
0
2019/1/7
2
0
2019/1/8
78
56
2019/1/9
19
53
2019/1/10
95
50
数据附件:
a.txt
b.txt
create table a(`date` string,v1 int) row format delimited fields
terminated by '\t';
create table b(`date` string,v2 int) row format delimited fields
terminated by '\t';
select nvl(a.date,b.date) as dt1,nvl(a.v1,0) as v1,nvl(b.v2,0) as v2
from a full join b on a.date = b.date
3. SQL 试题三
有一个拉链表:存款利率表 bal_rat_table,数据如下:
id
bal
rate
startDate
endDate
1
100
0.1
2018-12-01
2019-02-06
2
100
0.1
2018-09-01
2019-03-05
1
150
0.1
2019-02-06
2019-04-30
3
200
0.1
2019-01-04
2019-03-25
4
300
0.1
2019-01-01
9999-12-31
1
200
0.1
2019-04-30
9999-12-31
2
200
0.1
2019-03-05
9999-12-31
3
250
0.1
2019-03-25
9999-12-31
id:用户 id 、bal:用户存款、rate:利率、startDate:开始时间、endDate:结
束日期,9999 代表不知道何时结束。
需求:拉链表中存在多种状态的数据(存款),开始日期和结束日期不一致,求出 2019
年第一个季度:2019-01-01 至 2019-03-31 的每个人的利息。
数据附件:
bal_rat_table.txt
create table bal_rat_table(id int,bal int,rate double,startdate
string,enddate string) row format delimited fields terminated by '\t';
SELECT
id,
sum(
bal * rate * datediff(
IF (
enddate > '2019-03-31',
'2019-03-31',
enddate
剩余19页未读,继续阅读
资源评论
Java毕设王
- 粉丝: 6322
- 资源: 1075
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功