日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

hive数据库numeric_hive中常用的函数

發布時間:2023/12/13 数据库 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 hive数据库numeric_hive中常用的函数 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

目錄:

1.date_sub (string statdate, int days)?--返回到statdate之前int days的日期

2.concat(str1,str2,...)--將多個字符串連接成一個字符串

3.contact_ws(eperator,str1,str2...)--這個函數會跳過分隔符參數后的任何null和空字符串,分隔符將被加到被連接的字符串之間

4.sum(if(category=1,1,0))--sum函數返回一個數值,如果,category=1,則返回1,否則,返回0

count(if(category=1,true,null))--count函數返回一個布爾值類型的數據(即當返回值為true時進行計數)

5.variance(col)--求指定列數值的方差

1.date_sub()函數

作用:返回到statdate之前int days的日期

使用:date_sub (string statdate, int days)

eg:date_sub('2019-02-26',10)--------2019-02-16

題外話:

hive的書寫順序:

select … from … where … group by … having … order by …

hive的執行順序:

from … where … select … group by … having … order by …

2.concat()函數

將多個字符串連接成一個字符串

eg:select id,name from B limt 1

id ?name

1 ? ?lon

concat(str1,str2,...)

返回的結果為連接string產生的字符串,如果其中有任何一個參數為null,則返回的值為null

select concat(id,',',name) col from B limit 1

col

1,lon----------相當于用,把1和lon連接起來了

3.contact_ws(eperator,str1,str2...)

這個函數會跳過分隔符參數后的任何null和空字符串,分隔符將被加到被連接的字符串之間

eg:select concat_ws(',','aa','bb')

'aa,bb'

更新于2019-02-26

4.sum(if())和count(if())

sum(if(category=1,1,0)),sum函數返回一個數值,如果,category=1,則返回1,否則,返回0

count(if(category=1,true,null)),count函數返回一個布爾值類型的數據(即當返回值為true時進行計數),如果category=1,返回true,否則,返回null

count(if(category=1,1,0))--返回的全部都是true,即全部都會計數

5.variance(col)--return the wariance of a numeric column in the group.

求指定列數值的方差

6.lateral view explode()函數

explode()可以將數列類型拆分成多行--行轉列

lateral view可以進行相關的聚合

對應拆分

explode將復雜結構一行拆成多行,然后再用lateral view做各種聚合。

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的hive数据库numeric_hive中常用的函数的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。