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

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

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

          <bdo id='w4Mkm'></bdo><ul id='w4Mkm'></ul>
      1. <legend id='w4Mkm'><style id='w4Mkm'><dir id='w4Mkm'><q id='w4Mkm'></q></dir></style></legend>

      2. 如何在 MySQL 中執行分組排名

        How to perform grouped ranking in MySQL(如何在 MySQL 中執行分組排名)
        <i id='coD2d'><tr id='coD2d'><dt id='coD2d'><q id='coD2d'><span id='coD2d'><b id='coD2d'><form id='coD2d'><ins id='coD2d'></ins><ul id='coD2d'></ul><sub id='coD2d'></sub></form><legend id='coD2d'></legend><bdo id='coD2d'><pre id='coD2d'><center id='coD2d'></center></pre></bdo></b><th id='coD2d'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='coD2d'><tfoot id='coD2d'></tfoot><dl id='coD2d'><fieldset id='coD2d'></fieldset></dl></div>

            <tbody id='coD2d'></tbody>

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

              <legend id='coD2d'><style id='coD2d'><dir id='coD2d'><q id='coD2d'></q></dir></style></legend>
              1. <tfoot id='coD2d'></tfoot>
                  <bdo id='coD2d'></bdo><ul id='coD2d'></ul>
                • 本文介紹了如何在 MySQL 中執行分組排名的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  所以我有一個表格如下:

                  So I have a table as follows:

                  ID_STUDENT | ID_CLASS | GRADE
                  -----------------------------
                     1       |    1     |  90
                     1       |    2     |  80
                     2       |    1     |  99
                     3       |    1     |  80
                     4       |    1     |  70
                     5       |    2     |  78
                     6       |    2     |  90
                     6       |    3     |  50
                     7       |    3     |  90
                  

                  然后我需要對它們進行分組、排序和排序:

                  I need to then group, sort and order them to give:

                  ID_STUDENT | ID_CLASS | GRADE | RANK
                  ------------------------------------
                      2      |    1     |  99   |  1
                      1      |    1     |  90   |  2
                      3      |    1     |  80   |  3
                      4      |    1     |  70   |  4
                      6      |    2     |  90   |  1
                      1      |    2     |  80   |  2
                      5      |    2     |  78   |  3
                      7      |    3     |  90   |  1
                      6      |    3     |  50   |  2
                  

                  現在我知道你可以使用臨時變量來進行排名,像這里,但我如何為分組集做這件事?感謝您的任何見解!

                  Now I know that you can use a temp variable to rank, like here, but how do I do it for a grouped set? Thanks for any insight!

                  推薦答案

                  SELECT id_student, id_class, grade,
                     @student:=CASE WHEN @class <> id_class THEN 0 ELSE @student+1 END AS rn,
                     @class:=id_class AS clset
                  FROM
                    (SELECT @student:= -1) s,
                    (SELECT @class:= -1) c,
                    (SELECT *
                     FROM mytable
                     ORDER BY id_class, id_student
                    ) t
                  

                  這很簡單:

                  1. 初始查詢按 id_class 先排序,id_student 第二排序.
                  2. @student@class 被初始化為 -1
                  3. @class 用于測試是否輸入了下一組.如果 id_class 的先前值(存儲在 @class 中)不等于當前值(存儲在 id_class 中),@student 被歸零.否則遞增.
                  4. @class 被賦值為 id_class 的新值,它將在下一行的第 3 步的測試中使用.
                  1. Initial query is ordered by id_class first, id_student second.
                  2. @student and @class are initialized to -1
                  3. @class is used to test if the next set is entered. If the previous value of the id_class (which is stored in @class) is not equal to the current value (which is stored in id_class), the @student is zeroed. Otherwise is is incremented.
                  4. @class is assigned with the new value of id_class, and it will be used in test on step 3 at the next row.

                  這篇關于如何在 MySQL 中執行分組排名的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='2iexX'></bdo><ul id='2iexX'></ul>

                      <small id='2iexX'></small><noframes id='2iexX'>

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

                            主站蜘蛛池模板: 国产乱码精品一区二区三区中文 | 久久福利电影 | 精品久久久久久久久久久久久 | 在线2区| 男人久久天堂 | 欧美日韩一区在线观看 | 国产精品久久久久久一区二区三区 | 欧美一级欧美一级在线播放 | 一本色道精品久久一区二区三区 | 欧美日韩在线免费观看 | 精品一区二区电影 | 日韩欧美中文在线 | 九九热在线视频 | 久久久久久久久久久久91 | 精品日韩一区二区三区 | 精品在线一区 | 91精品久久久久久久久 | 国产精品美女久久久久aⅴ国产馆 | 国产中文视频 | 欧美区日韩区 | 亚洲天堂一区二区 | 欧美精品在线免费观看 | 精品久久久久一区二区国产 | 亚洲色在线视频 | 四虎永久免费影院 | 亚洲欧洲成人av每日更新 | 亚洲美女视频 | 久久精品亚洲一区二区三区浴池 | 日韩精品一区二区久久 | 国产高清av免费观看 | 精品久久久久久久久久久 | 999久久久 | 欧美日本韩国一区二区三区 | 精品国产欧美一区二区 | 二区在线视频 | 美女黄18岁以下禁止观看 | k8久久久一区二区三区 | 精品国产一区探花在线观看 | 久久精品视频一区二区三区 | 亚洲国产精品一区在线观看 | 在线观看免费黄色片 |