对比Excel的10个功能,学习SQL好像也快了?
SQL,数据分析岗的必备技能,你可以不懂Python,R,不懂可视化,不懂机器学习。但SQL,你必须懂。要不然领导让你跑个数据来汇......,哦不,你不懂SQL都无法入职数据分析岗,更别说领导了。
create table sale_guang SELECT * from sale where city='广州';
SELECT * from sale a
inner JOIN
(SELECT ordernum,profit from sale_guang) b style='margin: -0.8em 0px; color: rgb(26, 26, 26); font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Microsoft YaHei', 'Source Han Sans SC', 'Noto Sans CJK SC', 'WenQuanYi Micro Hei', sans-serif; font-size: medium; background-color: rgb(255, 255, 255); '>
SELECT * from sale a
WHERE a.ordernum not in
(SELECT b.ordernum from sale_guang b);
SELECT * FROM sale
where salesnum not in
(SELECT salesnum from sale GROUP BY salesman HAVING COUNT(salesnum)>1)
#用0填充:update sale set city = 0 where city = NULL
#删除有缺失值的行:delete from sale where city = NULL;
SELECT * from sale
where salesman = '张爱'
and city = '北京'
and orderaccount >=6000;
需求:筛选存货名称含有'三星'或则含有'索尼'的信息。
SELECT * from sale
where inventoryname like '%三星%' or 存货名称 like '%索尼%';
需求:北京区域各业务员的利润总额。
SELECT city,sum(`profit`) from sale
WHERE city = '北京'
GROUP BY `city`;
#有多少个?SELECT COUNT(*) from sale
where inventoryname like '%三星%'
and `tax` > 1000 ;
#这些订单的利润总和和平均利润是多少?SELECT `ordernum`,SUM(profit),AVG(`profit`) from sale
where inventoryname like '%三星%'
and `tax` > 1000
GROUP BY `ordernum`;
SELECT trim(inventoryname) from sale;
SELECT city,ordernum,(Nontaxamount - profit) as cost from sale
order by cost DESC;
总结:结构化查询语言(Structured Query Language)简称SQL,果然和它名字一样,查询起来得心应手,但做想做数据处理方面,能明细感受到比Python和excel吃力(也可能是我还没学好orz)。
赞 (0)