楼主: Joanmy
5320 1

[其它] 数据分析师笔试题 [推广有奖]

  • 2关注
  • 4粉丝

已卖:831份资源

博士生

7%

还不是VIP/贵宾

-

威望
0
论坛币
3912 个
通用积分
372.2829
学术水平
13 点
热心指数
28 点
信用等级
11 点
经验
3571 点
帖子
124
精华
0
在线时间
252 小时
注册时间
2013-9-15
最后登录
2024-4-23

楼主
Joanmy 在职认证  发表于 2016-3-28 21:06:06 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
最近在准备数据分析师的笔试,然后遇到了一些数据库的题目,以Oracle数据库为例。代码已经测试过可以使用,但是感觉写得太烦了,还请懂SQL得大神帮我改改。

sql查询语句相关问题

有一个计费表 表名 jifei字段如下: phone(8位的电话号码), month(月份),expenses(月消费,费用为0表明该月没有产生费用)

下面是该表的一条记录:64262631,201011,30.6这条记录的含义就是64262631的号码在2010年11月份产生了30.6元的话费。

按照要求写出满足下列条件的sql语句:

1、查找2010年6、7、8月有话费产生但9、10月没有使用并(6、7、8月话费均在51-100元之间的用户。

select distinctphone from jifei

where month='201006'and

expenses between 51and 100

and phone in (

select distinctphone from jifei

where month='201007'

and expenses between51 and 100)

and phone in (

select distinctphone from jifei

where month='201008'

and expenses between51 and 100)

and phone in (

select distinctphone from jifei

where month='201009'

and expenses =0)

and phone in (

select distinctphone from jifei

where month='201010'

and expenses =0)

;

2、查找2010年以来(截止到10月31日)所有后四位尾数符合AABB或者ABAB或者AAAA的电话号码。(A、 B 分别代表1—9中任意的一个数字)

select distinctphone from jifei

whereto_date(month,'yyyymm')<=to_date('201010 ','yyyymm')

and(substr(phone,5,1)=substr(phone,6,1)

andsubstr(phone,7,1)=substr(phone,8,1))

or(substr(phone,5,1)=substr(phone,7,1)

andsubstr(phone,6,1)=substr(phone,8,1))

or(substr(phone,5,1)=substr(phone,6,1)

andsubstr(phone,5,1)=substr(phone,7,1)

andsubstr(phone,5,1)=substr(phone,8,1)

andsubstr(phone,5,1)=substr(phone,9,1))

;

3、删除jifei表中所有10月份出现的两条相同记录中的其中一条记录。

方法:添加一列ID,作为主键

delete from jifei a

wheresubstr(a.month,5,2)='10'

and(a.phone,a.month) in

(select phone,monthfrom jifei

group by phone,month

havingcount(*)>1)

and a.id not in (

select min(id) fromjifei

group by phone,month

havingcount(*)>1) ;

4、查询所有9月份、10月份月均使用金额在30元以上的用户号码(结果不能出现重复)

select phone from (

selectphone,avg(expenses) as avg_exp from(

select distinct *from jifei

wheresubstr(month,5,2) in ('09','10'))

group by phone)

whereavg_exp>=30;


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:数据分析师 数据分析 分析师 笔试题 expenses oracle SQL 数据分析师 笔试题

沙发
casting 发表于 2016-3-30 07:15:22
不错,收藏学习了,多谢楼主

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
扫码
拉您进交流群
GMT+8, 2026-1-17 14:49