国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁(yè) > news >正文

wordpress主題樣式seo軟件資源

wordpress主題樣式,seo軟件資源,做網(wǎng)站最主要是什么,河北建設(shè)官方網(wǎng)站目錄 準(zhǔn)備工作: 在hive中建表 在presto中計(jì)算 分解式 按照城市分組 統(tǒng)計(jì)人數(shù) 按照性別分組 統(tǒng)計(jì)人數(shù) ?編輯 按照愛好分組 統(tǒng)計(jì)人數(shù) ?編輯 按照城市和性別分組 統(tǒng)計(jì)人數(shù) 按照城市和愛好分組 統(tǒng)計(jì)人數(shù) 按照性別和愛好分組 統(tǒng)計(jì)人數(shù) 按照城市和性別還有…

目錄

準(zhǔn)備工作:

在hive中建表

在presto中計(jì)算

分解式

按照城市分組 統(tǒng)計(jì)人數(shù)

按照性別分組 統(tǒng)計(jì)人數(shù)

?編輯

按照愛好分組 統(tǒng)計(jì)人數(shù)

?編輯

按照城市和性別分組 統(tǒng)計(jì)人數(shù)

按照城市和愛好分組 統(tǒng)計(jì)人數(shù)

按照性別和愛好分組 統(tǒng)計(jì)人數(shù)

按照城市和性別還有愛好分組 統(tǒng)計(jì)人數(shù)

統(tǒng)計(jì)人數(shù)

合并式

presto使用grouping

presto使用grouping sets

grouping作用例子展示

高級(jí)用法: cube

rollup 用法


準(zhǔn)備工作:

在hive中建表
drop database if exists db_test cascade;create database db_test;create table db_test.tb_student(name string,score   int,city    string,sex string,hobby string
)
row format delimited fields terminated by '\t';load data local inpath '/test/student.txt' into table db_test.tb_student;select * from db_test.tb_student;

student.txt數(shù)據(jù)

張三 ? ?10 ? ? ?北京 ? ?男 ? ? ?喝酒
李四 ? ?20 ? ? ?北京 ? ?男 ? ? ?抽煙
王五 ? ?30 ? ? ?北京 ? ?女 ? ? ?燙頭
趙六 ? ?40 ? ? ?上海 ? ?男 ? ? ?抽煙
麻七 ? ?50 ? ? ?上海 ? ?女 ? ? ?燙頭

在presto中計(jì)算

分解式
按照城市分組 統(tǒng)計(jì)人數(shù)
select city,count(1) as cnt from hive.db_test.tb_student group by city;

按照性別分組 統(tǒng)計(jì)人數(shù)
select hobby,count(1) as cnt from hive.db_test.tb_student group by hobby;
按照愛好分組 統(tǒng)計(jì)人數(shù)
select hobby,count(1) as cnt from hive.db_test.tb_student group by hobby;
按照城市和性別分組 統(tǒng)計(jì)人數(shù)
select city, sex, count(1) as cnt from hive.db_test.tb_student group by city, sex;

按照城市和愛好分組 統(tǒng)計(jì)人數(shù)
select city, hobby, count(1) as cnt from hive.db_test.tb_student group by city, hobby;

按照性別和愛好分組 統(tǒng)計(jì)人數(shù)
select sex, hobby, count(1) as cnt from hive.db_test.tb_student group by sex, hobby;

按照城市和性別還有愛好分組 統(tǒng)計(jì)人數(shù)
select city, sex, hobby, count(1) as cnt from hive.db_test.tb_student group by city, sex, hobby;

統(tǒng)計(jì)人數(shù)
select count(1) as cnt from hive.db_test.tb_student group by ();

合并式
with t1 as (select city, null as sex, null as hobby, count(1) as cnt, 1 as o from hive.db_test.tb_student group by cityunion allselect null as city, sex, null as hobby, count(1) as cnt, 2 as o from hive.db_test.tb_student group by sexunion allselect null, null, hobby,count(1) as cnt, 3 as o from hive.db_test.tb_student group by hobbyunion allselect city, sex, null, count(1) as cnt, 4 as o from hive.db_test.tb_student group by city, sexunion allselect city, null, hobby, count(1) as cnt, 5 as o from hive.db_test.tb_student group by city, hobbyunion allselect null, sex, hobby, count(1) as cnt, 6 as o from hive.db_test.tb_student group by sex, hobbyunion allselect city, sex, hobby, count(1) as cnt, 7 as o from hive.db_test.tb_student group by city, sex, hobbyunion allselect null, null, null, count(1) as cnt, 8 as o from hive.db_test.tb_student group by ()
)
select * from t1
order by o, city, sex, hobby
;

presto使用grouping

selectcity,sex,count(1) as cnt,grouping(city, sex) as g
from hive.db_test.tb_student
group by city, sex
;

presto使用grouping sets

selectcity,sex,hobby,count(1) as cnt,grouping(city, sex, hobby)
from hive.db_test.tb_student
group by grouping sets (city, sex, hobby)
;

selectcity,sex,hobby,count(1) as cnt,grouping(city, sex, hobby)
from hive.db_test.tb_student
group by grouping sets (city, sex, hobby, (city, sex), (city, hobby), (sex, hobby), (city, sex, hobby), ())
;

selectcity,sex,hobby,count(1) as cnt,casewhen grouping(city, sex, hobby)=3 then 1when grouping(city, sex, hobby)=5 then 2when grouping(city, sex, hobby)=6 then 3when grouping(city, sex, hobby)=1 then 4when grouping(city, sex, hobby)=2 then 5when grouping(city, sex, hobby)=4 then 6when grouping(city, sex, hobby)=0 then 7when grouping(city, sex, hobby)=7 then 8else 100end as o
from hive.db_test.tb_student
group by grouping sets (city, sex, hobby, (city, sex), (city, hobby), (sex, hobby), (city, sex, hobby), ())
order by o, city, sex, hobby
;

grouping作用例子展示

with t1 as (select '北京' as city, '男' as sexunion allselect '北京' as city, '男' as sexunion allselect '北京' as city, '女' as sexunion allselect '北京' as city, null as sex
)
selectcity,sex,count(1) as cnt
from t1
group by grouping sets (city, (city, sex))

問題:city=北京, sex=null, cnt=4city=北京, sex=null, cnt=1為什么 city 和 sex 的值一樣, 但是結(jié)果不同?
原因:一個(gè)null 表示跟這一列沒有關(guān)系另一個(gè)null 表示 這一列的值 為null, 根據(jù) 列值統(tǒng)計(jì)的結(jié)果怎么區(qū)分
解決方案:grouping(city, sex)0,0     兩個(gè)都有關(guān)0,1     只跟city有關(guān)1,0     只跟sex有關(guān)1,1     都這兩列都無關(guān)
with t1 as (select '北京' as city, '男' as sexunion allselect '北京' as city, '男' as sexunion allselect '北京' as city, '女' as sexunion allselect '北京' as city, null as sex
)
selectcity,sex,count(1) as cnt,grouping(city, sex) g
from t1
group by grouping sets (city, (city, sex))

selectcity,sex,hobby,count(1) as cnt,casewhen grouping(city, sex, hobby)=3 then 1when grouping(city, sex, hobby)=5 then 2when grouping(city, sex, hobby)=6 then 3when grouping(city, sex, hobby)=1 then 4when grouping(city, sex, hobby)=2 then 5when grouping(city, sex, hobby)=4 then 6when grouping(city, sex, hobby)=0 then 7when grouping(city, sex, hobby)=7 then 8else 100end as o
from hive.db_test.tb_student
group by grouping sets (city, sex, hobby, (city, sex), (city, hobby), (sex, hobby), (city, sex, hobby), ())
order by o, city, sex, hobby

高級(jí)用法: cube

selectcity,sex,hobby,count(1) as cnt,casewhen grouping(city, sex, hobby)=3 then 1when grouping(city, sex, hobby)=5 then 2when grouping(city, sex, hobby)=6 then 3when grouping(city, sex, hobby)=1 then 4when grouping(city, sex, hobby)=2 then 5when grouping(city, sex, hobby)=4 then 6when grouping(city, sex, hobby)=0 then 7when grouping(city, sex, hobby)=7 then 8else 100end as o
from hive.db_test.tb_student
group by cube(city, sex, hobby)
order by o, city, sex, hobby

rollup 用法

selectcity,sex,hobby,count(1) as cnt,casewhen grouping(city, sex, hobby)=3 then 1when grouping(city, sex, hobby)=5 then 2when grouping(city, sex, hobby)=6 then 3when grouping(city, sex, hobby)=1 then 4when grouping(city, sex, hobby)=2 then 5when grouping(city, sex, hobby)=4 then 6when grouping(city, sex, hobby)=0 then 7when grouping(city, sex, hobby)=7 then 8else 100end as o
from hive.db_test.tb_student
group by rollup(city, sex, hobby)
order by o, city, sex, hobby
;

總結(jié):

presto時(shí)間函數(shù):

date()類型 表示 年月日

timestamp類型表示 年月日時(shí)分秒

eg:timestamp('2024-08-18 22:13:10','%Y-%m-%d %H%i%s')

date_add(unit, value,timestamp)?

grouping sets()相當(dāng)于一個(gè)集合 都能根據(jù)括號(hào)里的內(nèi)容分組查詢到相應(yīng)的數(shù)據(jù)

grouping 根據(jù)8421碼 0表示與該列有關(guān)系1表示無關(guān) 通過計(jì)算數(shù)值 查看與列之間分組的關(guān)系

cube(city, sex, hobby) 等價(jià)于 grouping sets (city, sex, hobby, (city, sex), (city, hobby), (sex, hobby), (city, sex, hobby), ())

rollup?(city,?sex,?name)?等價(jià)于?grouping set((city,?sex,?name), (city,?sex), city, ())

http://aloenet.com.cn/news/45355.html

相關(guān)文章:

  • 挖礦網(wǎng)站怎么做seo技術(shù)培訓(xùn)寧波
  • 郴州百度seoseo入門教學(xué)
  • 國(guó)內(nèi)網(wǎng)站不備案品牌推廣的方式有哪些
  • 今天八點(diǎn)發(fā)布的株洲疫情網(wǎng)站搜索引擎優(yōu)化主要方法
  • 網(wǎng)站圖片鏈接到視頻怎么做微信營(yíng)銷推廣
  • 婚慶公司加盟連鎖品牌廣告優(yōu)化
  • 哪個(gè)網(wǎng)站專門做母嬰東營(yíng)網(wǎng)站推廣公司
  • 上海app制作灰色行業(yè)seo
  • 自己建一個(gè)網(wǎng)站難嗎網(wǎng)站怎么營(yíng)銷推廣
  • 五合一小程序網(wǎng)站推廣網(wǎng)站排名
  • 四川網(wǎng)站建設(shè)套餐北京網(wǎng)站seo設(shè)計(jì)
  • ppt做雜志模板下載網(wǎng)站搜索引擎排行榜前十名
  • 免費(fèi)的黃岡網(wǎng)站有哪些代碼系統(tǒng)優(yōu)化的意義
  • 把網(wǎng)站傳到服務(wù)器上怎么做新媒體運(yùn)營(yíng)
  • 做網(wǎng)站是怎樣賺錢深圳全網(wǎng)營(yíng)銷哪里好
  • 網(wǎng)站的排名優(yōu)化怎么做怎么做網(wǎng)頁(yè)設(shè)計(jì)的頁(yè)面
  • js網(wǎng)站模板下載軟文推廣例子
  • 關(guān)于企業(yè)網(wǎng)站建設(shè)的請(qǐng)示高清網(wǎng)站推廣免費(fèi)下載
  • 網(wǎng)站建設(shè) 中企動(dòng)力公司中山做網(wǎng)站推廣公司
  • 營(yíng)銷策劃的流程南昌seo網(wǎng)站排名
  • 網(wǎng)站備案是空間備案還是域名備案友情鏈接大全
  • 設(shè)計(jì)網(wǎng)站的元素萬網(wǎng)域名管理入口
  • 做網(wǎng)站需要多少固定帶寬seo人才網(wǎng)
  • 下載網(wǎng)上國(guó)網(wǎng)app汕頭seo收費(fèi)
  • 彩票網(wǎng)站開發(fā)風(fēng)險(xiǎn)國(guó)外網(wǎng)站制作
  • 新疆所有的網(wǎng)站百度知道客服
  • 一些網(wǎng)站是用什么顏色做的怎么申請(qǐng)建立網(wǎng)站
  • 網(wǎng)站開發(fā)設(shè)計(jì)實(shí)訓(xùn) 報(bào)告蘇州seo關(guān)鍵詞優(yōu)化方法
  • 鹽城有沒有做網(wǎng)站嗎湖南專業(yè)的關(guān)鍵詞優(yōu)化
  • 鎮(zhèn)江網(wǎng)站制作優(yōu)化老哥們給個(gè)關(guān)鍵詞