
SQL,数据分析岗的必备技能,你可以不懂Python,R,不懂可视化,不懂机器学习。但SQL,你必须懂。要不然领导让你跑个数据来汇......,哦不,你不懂SQL都无法入职数据分析岗,更别说领导了。
create table sale_guang SELECT * from sale where city="广州";
SELECT * from sale ainner 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 aWHERE a.ordernum not in(SELECT b.ordernum from sale_guang b);
SELECT * FROM salewhere 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 salewhere salesman = "张爱"and city = "北京"and orderaccount >=6000;
需求:筛选存货名称含有"三星"或则含有"索尼"的信息。
SELECT * from salewhere inventoryname like "%三星%" or 存货名称 like "%索尼%";
需求:北京区域各业务员的利润总额。
SELECT city,sum(`profit`) from saleWHERE city = "北京"GROUP BY `city`;
#有多少个?SELECT COUNT(*) from salewhere inventoryname like "%三星%"and `tax` > 1000 ;#这些订单的利润总和和平均利润是多少?SELECT `ordernum`,SUM(profit),AVG(`profit`) from salewhere inventoryname like "%三星%"and `tax` > 1000GROUP BY `ordernum`;
SELECT trim(inventoryname) from sale;
SELECT city,ordernum,(Nontaxamount - profit) as cost from saleorder by cost DESC;
总结:结构化查询语言(Structured Query Language)简称SQL,果然和它名字一样,查询起来得心应手,但做想做数据处理方面,能明细感受到比Python和excel吃力(也可能是我还没学好orz)。
往期推荐:
为了探究妹纸对 “bra” 的喜好!趁着“双11”来临之际,我爬取了淘宝......
CSDN文章被洗稿、抄袭严重!用Python做一个“基于搜索引擎的文章查重工具”,解决!


