久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='DrmMP'></bdo><ul id='DrmMP'></ul>
    <tfoot id='DrmMP'></tfoot>
    <i id='DrmMP'><tr id='DrmMP'><dt id='DrmMP'><q id='DrmMP'><span id='DrmMP'><b id='DrmMP'><form id='DrmMP'><ins id='DrmMP'></ins><ul id='DrmMP'></ul><sub id='DrmMP'></sub></form><legend id='DrmMP'></legend><bdo id='DrmMP'><pre id='DrmMP'><center id='DrmMP'></center></pre></bdo></b><th id='DrmMP'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='DrmMP'><tfoot id='DrmMP'></tfoot><dl id='DrmMP'><fieldset id='DrmMP'></fieldset></dl></div>

    1. <small id='DrmMP'></small><noframes id='DrmMP'>

      1. <legend id='DrmMP'><style id='DrmMP'><dir id='DrmMP'><q id='DrmMP'></q></dir></style></legend>

        在“GROUP BY"中重用選擇表達(dá)式的結(jié)果;條款

        reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用選擇表達(dá)式的結(jié)果;條款?)
          <tbody id='ap0jb'></tbody>
        <i id='ap0jb'><tr id='ap0jb'><dt id='ap0jb'><q id='ap0jb'><span id='ap0jb'><b id='ap0jb'><form id='ap0jb'><ins id='ap0jb'></ins><ul id='ap0jb'></ul><sub id='ap0jb'></sub></form><legend id='ap0jb'></legend><bdo id='ap0jb'><pre id='ap0jb'><center id='ap0jb'></center></pre></bdo></b><th id='ap0jb'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ap0jb'><tfoot id='ap0jb'></tfoot><dl id='ap0jb'><fieldset id='ap0jb'></fieldset></dl></div>
        1. <small id='ap0jb'></small><noframes id='ap0jb'>

              <tfoot id='ap0jb'></tfoot>
                <bdo id='ap0jb'></bdo><ul id='ap0jb'></ul>

                  <legend id='ap0jb'><style id='ap0jb'><dir id='ap0jb'><q id='ap0jb'></q></dir></style></legend>
                  本文介紹了在“GROUP BY"中重用選擇表達(dá)式的結(jié)果;條款?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  在 MySQL 中,我可以有這樣的查詢:

                  In MySQL, I can have a query like this:

                  select  
                      cast(from_unixtime(t.time, '%Y-%m-%d %H:00') as datetime) as timeHour
                      , ... 
                  from
                      some_table t 
                  group by
                      timeHour, ...
                  order by
                      timeHour, ...
                  

                  其中 GROUP BY 中的 timeHour 是選擇表達(dá)式的結(jié)果.

                  where timeHour in the GROUP BY is the result of a select expression.

                  但是我剛剛嘗試了一個類似于 Sqark SQL 中的查詢,我得到了一個錯誤

                  But I just tried a query similar to that in Sqark SQL, and I got an error of

                  Error: org.apache.spark.sql.AnalysisException: 
                  cannot resolve '`timeHour`' given input columns: ...
                  

                  我對 Spark SQL 的查詢是這樣的:

                  My query for Spark SQL was this:

                  select  
                        cast(t.unixTime as timestamp) as timeHour
                      , ...
                  from
                      another_table as t
                  group by
                      timeHour, ...
                  order by
                      timeHour, ...
                  

                  這個結(jié)構(gòu)在 Spark SQL 中可行嗎?

                  Is this construct possible in Spark SQL?

                  推薦答案

                  這個結(jié)構(gòu)在 Spark SQL 中可行嗎?

                  Is this construct possible in Spark SQL?

                  是的,是.您可以通過兩種方式使其在 Spark SQL 中工作,以在 GROUP BYORDER BY 子句中使用新列

                  Yes, It is. You can make it works in Spark SQL in 2 ways to use new column in GROUP BY and ORDER BY clauses

                  使用子查詢的方法一:

                  SELECT timeHour, someThing FROM (SELECT  
                        from_unixtime((starttime/1000)) AS timeHour
                      , sum(...)                          AS someThing
                      , starttime
                  FROM
                      some_table) 
                  WHERE
                      starttime >= 1000*unix_timestamp('2017-09-16 00:00:00')
                        AND starttime <= 1000*unix_timestamp('2017-09-16 04:00:00')
                  GROUP BY
                      timeHour
                  ORDER BY
                      timeHour
                  LIMIT 10;
                  

                  方法 2 使用 WITH//優(yōu)雅的方式:

                  -- create alias 
                  WITH table_aliase AS(SELECT  
                        from_unixtime((starttime/1000)) AS timeHour
                      , sum(...)                          AS someThing
                      , starttime
                  FROM
                      some_table)
                  
                  -- use the same alias as table
                  SELECT timeHour, someThing FROM table_aliase
                  WHERE
                      starttime >= 1000*unix_timestamp('2017-09-16 00:00:00')
                        AND starttime <= 1000*unix_timestamp('2017-09-16 04:00:00')
                  GROUP BY
                      timeHour
                  ORDER BY
                      timeHour
                  LIMIT 10;
                  

                  在 Scala 中使用 Spark DataFrame(wo SQL) API 的替代方法:

                  // This code may need additional import to work well
                  
                  val df = .... //load the actual table as df
                  
                  import org.apache.spark.sql.functions._
                  
                  df.withColumn("timeHour", from_unixtime($"starttime"/1000))
                    .groupBy($"timeHour")
                    .agg(sum("...").as("someThing"))
                    .orderBy($"timeHour")
                    .show()
                  
                  //another way - as per eliasah comment
                  df.groupBy(from_unixtime($"starttime"/1000).as("timeHour"))
                    .agg(sum("...").as("someThing"))
                    .orderBy($"timeHour")
                    .show()
                  

                  這篇關(guān)于在“GROUP BY"中重用選擇表達(dá)式的結(jié)果;條款?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函數(shù)根據(jù) N 個先前值來決定接下來的 N 個行)
                  reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用選擇表達(dá)式的結(jié)果;條款?)
                  Does ignore option of Pyspark DataFrameWriter jdbc function ignore entire transaction or just offending rows?(Pyspark DataFrameWriter jdbc 函數(shù)的 ignore 選項是忽略整個事務(wù)還是只是有問題的行?) - IT屋-程序員軟件開發(fā)技
                  Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 時出錯,使用 for 循環(huán)數(shù)組)
                  pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 調(diào)用 o23.load 時發(fā)生錯誤 沒有合適的驅(qū)動程序)
                  How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何將 Apache Spark 與 MySQL 集成以將數(shù)據(jù)庫表作為 Spark 數(shù)據(jù)幀讀取?)
                    <tbody id='pyZrq'></tbody>

                        • <bdo id='pyZrq'></bdo><ul id='pyZrq'></ul>
                        • <small id='pyZrq'></small><noframes id='pyZrq'>

                          1. <tfoot id='pyZrq'></tfoot>
                            <legend id='pyZrq'><style id='pyZrq'><dir id='pyZrq'><q id='pyZrq'></q></dir></style></legend>
                            <i id='pyZrq'><tr id='pyZrq'><dt id='pyZrq'><q id='pyZrq'><span id='pyZrq'><b id='pyZrq'><form id='pyZrq'><ins id='pyZrq'></ins><ul id='pyZrq'></ul><sub id='pyZrq'></sub></form><legend id='pyZrq'></legend><bdo id='pyZrq'><pre id='pyZrq'><center id='pyZrq'></center></pre></bdo></b><th id='pyZrq'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='pyZrq'><tfoot id='pyZrq'></tfoot><dl id='pyZrq'><fieldset id='pyZrq'></fieldset></dl></div>
                            主站蜘蛛池模板: 久久久日韩精品一区二区三区 | 福利网站在线观看 | 成人污污视频 | 国产精品国产三级国产aⅴ无密码 | a视频在线观看 | 请别相信他免费喜剧电影在线观看 | 91精品国产乱码久久久 | 日韩欧美操 | 免费一区二区三区 | 久久久久久久国产精品影院 | 一区二区三区av | 欧美精品1区2区3区 免费黄篇 | www国产成人免费观看视频,深夜成人网 | 三级成人片| 日韩欧美一区二区三区四区 | 7777在线视频免费播放 | 亚洲美女在线一区 | 一级a性色生活片久久毛片 一级特黄a大片 | 中文字幕精品一区 | 国产精品一区二区三区久久 | 亚洲国产自产 | 久久网一区二区 | 久久久久久免费精品一区二区三区 | 亚洲高清视频一区二区 | 国产乱码精品一区二区三区五月婷 | 人人擦人人| 亚洲 欧美 另类 综合 偷拍 | 黄网免费看 | 亚洲精品视频一区二区三区 | 狠狠爱综合 | 久久亚洲天堂 | 99re在线视频 | 一本色道精品久久一区二区三区 | 国产精品久久久久久久久久免费 | 欧美在线观看一区 | 国产四虎 | 一区二区三区四区在线 | 福利社午夜影院 | 国内精品久久久久久 | 狠狠爱免费视频 | 91在线第一页 |