name ? ?course ? ? ? grade
張三 ? ? 語文 ? ? ? 81
張三 ? ? ?數(shù)學(xué) ? ? ? 75
李四 ? ? 語文 ? ? ? 76
李四 ? ? ?數(shù)學(xué) ? ? ? 90
王五 ? ? ?語文 ? ? ? 81
王五 ? ? ?數(shù)學(xué) ? ? ?100
王五 ? ? 英語 ? ? ? 90
數(shù)據(jù)查找
對比excel消请,顯示我們需要的行和列
查找行:filter,多條件組合
查找列:把不要的列隱藏起來
查重
sql:
select * from tablename where column = 'xxx'
select course,grade from t_2017 where grade>=90
數(shù)據(jù)處理
對比excel
文本:left,right,if
時間:時間函數(shù)
sql:
文本:left审轮,right,if
時間:時間函數(shù)
select *,left(course,1) as new,now() as d from t_2017
數(shù)據(jù)統(tǒng)計
對比excel
使用透視表:先對列數(shù)據(jù)篩選,然后將字段拖到透視表的行和列,可以選擇sum,count沪羔,max,min
sql:
篩選數(shù)據(jù):where
分組統(tǒng)計:group by
統(tǒng)計:sum象浑,count蔫饰,max,min
select name,avg(grade) as 平均分,max(grade) as 最高分 from t_2017 group by name
select course,avg(grade) as 平均分,count(*) as 考試人數(shù) from t_2017 group by course
數(shù)據(jù)關(guān)聯(lián)
對比excel
vlookup:通過兩張表關(guān)聯(lián)愉豺,組合一些字段
sql:
inner join 表示兩張表連起來死嗦,組合成一張新的大表
on 表示連接的方式,一般也就是字段相等
比如:
select * from customer
inner join mapping on customer.stc=mapping.stc