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

    <tfoot id='T1HrB'></tfoot>

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

    <small id='T1HrB'></small><noframes id='T1HrB'>

    1. 需要指導:后端 SQL 邏輯,用于前端用戶動態選擇

      Guidance needed: Backend SQL logic for dynamic selection of a field by users in frontend(需要指導:后端 SQL 邏輯,用于前端用戶動態選擇字段)
          • <bdo id='tefw5'></bdo><ul id='tefw5'></ul>
            <legend id='tefw5'><style id='tefw5'><dir id='tefw5'><q id='tefw5'></q></dir></style></legend>

                  <tbody id='tefw5'></tbody>

                <small id='tefw5'></small><noframes id='tefw5'>

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

                本文介紹了需要指導:后端 SQL 邏輯,用于前端用戶動態選擇字段的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我有一個數據集如下:

                Country,Commodity,Year,Type,Amount
                US,Vegetable,2010,Harvested,2.44
                US,Vegetable,2010,Yield,15.8
                US,Vegetable,2010,Production,6.48
                US,Vegetable,2011,Harvested,6
                US,Vegetable,2011,Yield,18
                US,Vegetable,2011,Production,3
                Argentina,Vegetable,2010,Harvested,15.2
                Argentina,Vegetable,2010,Yield,40.5
                Argentina,Vegetable,2010,Production,2.66
                Argentina,Vegetable,2011,Harvested,15.2
                Argentina,Vegetable,2011,Yield,40.5
                Argentina,Vegetable,2011,Production,2.66
                Bhutan,Vegetable,2010,Harvested,7
                Bhutan,Vegetable,2010,Yield,35
                Bhutan,Vegetable,2010,Production,5
                Bhutan,Vegetable,2011,Harvested,2
                Bhutan,Vegetable,2011,Yield,6
                Bhutan,Vegetable,2011,Production,3
                

                鑒于:

                1. 如果任何一個國家在數據中有 n 年,所有其他國家也應有相同的 n 年.例如:如果美國有 2011 年和 2012 年的數據,那么所有其他國家/地區都將有 2011 年和 2012 年的數據.

                條件:

                1. 聚合僅在多國選擇時發生.將按商品和年份分組.

                例如:如果前端工具中的用戶選擇美國和阿根廷,我們必須顯示 -

                Eg: If a user in the frontend tool selects US and Argentina, we have to show -

                衍生產量的數量 =(美國收獲量 + 阿根廷收獲量)/(美國產量 + 阿根廷產量),即 (2.44+15.2)/(6.48+2.66),同樣,對于三個國家,它將是三個收獲值的相加除以三個產值的相加,依此類推.必須將其填充到新行中.

                The Amount for Derived Yield = (Harvested of US + Harvested of Argentina)/(Production of US + Production of Argentina), i.e., (2.44+15.2)/(6.48+2.66), similarly for three countries it will be addition of three harvested value divided by addition of three production value and so on. That has to be populated in a new row.

                注意:前端用戶可以選擇任意國家/地區組合.在后端執行而不是在前端動態執行的唯一目的是因為 AWS QuickSight(我們的可視化工具)雖然可以在選定的列過濾器上填充總和,但尚不支持對那些衍生的求和字段進行計算.因此,必須預先填充所有國家/地區組合的整個計算(非常幼稚的方法),以便在報告中提供.

                Note: The users in the frontend can select any combination of countries. The sole purpose of doing it in the backend rather than dynamically doing it in the frontend is because AWS QuickSight (our visualisation tool), even though can populate sum on selected column filters but doesn't yet support calculation on those derived summed fields. Hence, the entire calculation of all combination of countries has to be pre-populated (very naive approach) in order to make it available in report.

                我向所有 SQL 專家提出的兩個問題是:

                Two of my question to all SQL experts is:

                • 如何填充按年份和商品分組的所有國家/地區組合的行,以便包含所有可能組合的數據.
                • 鑒于我可以填充所有行組合,報告工具將如何根據用戶選擇的國家/地區了解選擇哪個派生行,因為該行標記為美國 + 阿根廷,該行為美國 + 不丹,等

                非常歡迎任何解決方案.

                Any solution is extremely welcome.

                首選 SQL 工具:Spark SQL 或 Athena SQL(在 Presto 上運行)或 HiveQL.次選:Oracle、PGSQL

                SQL Tool preferred: Spark SQL or Athena SQL (runs on Presto) or HiveQL. Less preferred: Oracle, PGSQL

                注意 2:發布這個問題的唯一目的,即使我已經在另一個問題中詳細闡述過,也是因為我不想將我的天真方法強加給試圖解決問題的人問題,所以在這里,與尋求解決方案的幫助相比,我更清楚地定義了問題.而在另一個問題中,我已經給出了預期結果的方法.如果您想查看其他問題,這里是.

                Note 2: The sole purpose of posting this question, even though I've elaborated the same in another one is because I don't want to impose my naive approach on somebody trying to solve the problem, so here, I've defined the problem with more clarity than asking for help in solution. Whereas, in the other question I have given my approach for the expected result. In case if you want to see the other question, here it is.

                推薦答案

                你可以從這樣的事情開始:

                you can start with something like this:

                select * from
                (
                    select c.Country, y.Year
                    from
                    (select distinct Country from table) as c,
                    (select distinct Year from table) as y
                ) as cy
                left join table as t on t.Country = cy.Country and t.Year = cy.Year
                

                這將為您提供包含國家/年所有組合的所有行以及主表中的可選數據,因此您現在可以添加過濾器/分組

                this will give you all rows with all combinations of Country/Year and optionally data from main table, so you can now add filter/grouping

                這篇關于需要指導:后端 SQL 邏輯,用于前端用戶動態選擇字段的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 數據幀讀取?)

                  • <bdo id='jQAxy'></bdo><ul id='jQAxy'></ul>
                  • <tfoot id='jQAxy'></tfoot>

                  • <legend id='jQAxy'><style id='jQAxy'><dir id='jQAxy'><q id='jQAxy'></q></dir></style></legend>

                      <small id='jQAxy'></small><noframes id='jQAxy'>

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

                          主站蜘蛛池模板: 日韩精品一区二区三区高清免费 | 日韩欧美三区 | 视频一区中文字幕 | 日韩亚洲欧美一区 | 欧美日韩在线视频一区二区 | 91久久 | 欧美不卡一区二区 | 91视视频在线观看入口直接观看 | 欧美视频三区 | 久久国产成人 | 日本亚洲一区 | 精品在线观看一区二区 | 91久久 | 美女视频h | 欧美中文在线 | 国产日本精品视频 | 日本成人中文字幕 | 久草精品视频 | 精品久久影院 | 成人午夜免费视频 | 亚洲高清视频一区二区 | 精精国产xxxx视频在线 | 一级特黄视频 | 久久69精品久久久久久久电影好 | 久久高清精品 | 国产一区精品在线 | 国产高潮好爽受不了了夜色 | 国产欧美日韩综合精品一 | 欧美专区日韩专区 | 一区天堂 | 成人欧美一区二区三区黑人孕妇 | 国产资源在线播放 | 亚洲毛片在线观看 | av免费网站在线观看 | 国产精品一二三区 | h视频在线观看免费 | 日本黄色不卡视频 | 国产亚洲精品久久久优势 | 国产日韩欧美另类 | 99这里只有精品视频 | 日本在线免费 |