久久久久久久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"中重用選擇表達式的結果;條款

        reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用選擇表達式的結果;條款?)
          <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"中重用選擇表達式的結果;條款?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  在 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 是選擇表達式的結果.

                  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, ...
                  

                  這個結構在 Spark SQL 中可行嗎?

                  Is this construct possible in Spark SQL?

                  推薦答案

                  這個結構在 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//優雅的方式:

                  -- 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()
                  

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

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

                  相關文檔推薦

                  How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函數根據 N 個先前值來決定接下來的 N 個行)
                  reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用選擇表達式的結果;條款?)
                  Does ignore option of Pyspark DataFrameWriter jdbc function ignore entire transaction or just offending rows?(Pyspark DataFrameWriter jdbc 函數的 ignore 選項是忽略整個事務還是只是有問題的行?) - IT屋-程序員軟件開發技
                  Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 時出錯,使用 for 循環數組)
                  pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 調用 o23.load 時發生錯誤 沒有合適的驅動程序)
                  How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何將 Apache Spark 與 MySQL 集成以將數據庫表作為 Spark 數據幀讀取?)
                    <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>
                            主站蜘蛛池模板: 午夜激情在线观看 | 亚洲专区一区 | 在线看黄的网站 | 日韩免费一级片 | 伊人久久中文字幕 | 亚洲成人av在线播放 | 天天网综合 | 亚洲成人精品 | 天天视频国产 | 国产精品6 | 激情综 | 久久精品国产精品 | 日韩毛片网站 | 中文字幕永久在线 | 中文字幕精品一区久久久久 | 国产一区二区中文字幕 | av网站免费观看 | 欧美日韩在线一区 | 国模一区二区三区 | 男女瑟瑟视频 | 999在线视频| 亚洲第一伊人 | 艳妇乳肉豪妇荡乳 | 欧美做受| 久热久| 538在线视频| 婷婷狠狠 | 日韩中文字幕精品 | 国产中文字幕在线 | 中文字幕在线看片 | 一区二区网站 | 久久久久免费 | 免费毛片在线播放 | 国产二区三区 | 天堂av资源 | av香蕉| 免费在线观看www | 香蕉视频免费看 | 国模无码大尺度一区二区三区 | 国产成人一区二区 | 超碰在线成人 |