Commit 0e4a8b57 authored by 王志伟's avatar 王志伟

change sql

parent ca4d19f0
...@@ -50,7 +50,7 @@ object testt { ...@@ -50,7 +50,7 @@ object testt {
val view_count = sc.sql( val view_count = sc.sql(
s""" s"""
|select params["business_id"] as diary_id,sum(params["out"]-params["in"]) as dur_time,count(cl_id) as num_clk |select params["business_id"] as diary_id,(params["out"]-params["in"]) as dur_time
|from online.tl_hdfs_maidian_view |from online.tl_hdfs_maidian_view
|where action="page_view" |where action="page_view"
|and params["page_name"]="diary_detail" |and params["page_name"]="diary_detail"
...@@ -62,17 +62,10 @@ object testt { ...@@ -62,17 +62,10 @@ object testt {
view_count.show() view_count.show()
view_count.createOrReplaceTempView("temp") view_count.createOrReplaceTempView("temp")
val avg = sc.sql( GmeiConfig.writeToJDBCTable(view_count, "avg", SaveMode.Overwrite)
s"""
|select diary_id,dur_time,num_clk,(dur_time/num_clk) as avg
|from temp
|order by num_clk desc
""".stripMargin
)
GmeiConfig.writeToJDBCTable(avg, "avg", SaveMode.Overwrite)
val result = avg val result = view_count
result.show() result.show()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment