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

  • <small id='rAtA1'></small><noframes id='rAtA1'>

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

      1. SQL 平均(計數(*))?

        SQL AVG(COUNT(*))?(SQL 平均(計數(*))?)
          <tfoot id='Ttbzd'></tfoot>
            1. <legend id='Ttbzd'><style id='Ttbzd'><dir id='Ttbzd'><q id='Ttbzd'></q></dir></style></legend>

            2. <small id='Ttbzd'></small><noframes id='Ttbzd'>

                <tbody id='Ttbzd'></tbody>
                <bdo id='Ttbzd'></bdo><ul id='Ttbzd'></ul>

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

                2. 本文介紹了SQL 平均(計數(*))?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我試圖找出一個值在列中出現的平均次數,根據另一列對其進行分組,然后對其進行計算.

                  I'm trying to find out the average number of times a value appears in a column, group it based on another column and then perform a calculation on it.

                  我有 3 張桌子,有點像這樣

                  I have 3 tables a little like this

                  DVD
                  
                  ID | NAME
                  1  | 1       
                  2  | 1     
                  3  | 2      
                  4  | 3
                  
                  COPY 
                  
                  ID | DVDID   
                  1  | 1  
                  2  | 1  
                  3  | 2  
                  4  | 3  
                  5  | 1
                  
                  LOAN
                  
                  ID | DVDID | COPYID  
                  1  | 1     |  1  
                  2  | 1     |  2  
                  3  | 2     |  3    
                  4  | 3     |  4  
                  5  | 1     |  5
                  6  | 1     |  5
                  7  | 1     |  5
                  8  | 1     |  2
                  

                  基本上,我試圖找到出借表中出現的所有副本 ID,其次數少于該 DVD 的所有副本的平均次數.

                  Basically, I'm trying to find all the copy ids that appear in the loan table LESS times than the average number of times for all copies of that DVD.

                  因此在上面的示例中,dvd 1 的副本 5 出現了 3 次,副本 2 兩次,副本 1 一次,因此該 DVD 的平均值為 2.我想列出該 DVD 的所有副本(以及每個副本)在 Loan 表中出現的數字小于該數字.

                  So in the example above, copy 5 of dvd 1 appears 3 times, copy 2 twice and copy 1 once so the average for that DVD is 2. I want to list all the copies of that (and each other) dvd that appear less than that number in the Loan table.

                  我希望這更有意義...

                  I hope that makes a bit more sense...

                  謝謝

                  推薦答案

                  類似于 dotjoe 的解決方案,但使用解析函數來避免額外的連接.可能或多或少有效率.

                  Similar to dotjoe's solution, but using an analytic function to avoid the extra join. May be more or less efficient.

                  with 
                  loan_copy_total as 
                  (
                      select dvdid, copyid, count(*) as cnt
                      from loan
                      group by dvdid, copyid
                  ),
                  loan_copy_avg as
                  (
                      select dvdid, copyid, cnt, avg(cnt) over (partition by dvdid) as copy_avg
                      from loan_copy_total
                  )
                  select *
                  from loan_copy_avg lca
                  where cnt <= copy_avg;
                  

                  這篇關于SQL 平均(計數(*))?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  SQL query to get all products, categories and meta data woocommerce/wordpress(獲取所有產品、類別和元數據的 SQL 查詢 woocommerce/wordpress)
                  Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?(我可以在不編寫 SQL 查詢的情況下找出數據庫列表和 SQL Server 實例使用的空間嗎?) - IT屋-程序員軟件開發
                  How to create a login to a SQL Server instance?(如何創建對 SQL Server 實例的登錄?)
                  How to know the version and edition of SQL Server through registry search(如何通過注冊表搜索知道SQL Server的版本和版本)
                  Why do I get a quot;data type conversion errorquot; with ExecuteNonQuery()?(為什么會出現“數據類型轉換錯誤?使用 ExecuteNonQuery()?)
                  How to show an image from a DataGridView to a PictureBox?(如何將 DataGridView 中的圖像顯示到 PictureBox?)
                3. <legend id='ayqo7'><style id='ayqo7'><dir id='ayqo7'><q id='ayqo7'></q></dir></style></legend>

                  <tfoot id='ayqo7'></tfoot>

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

                            主站蜘蛛池模板: 91免费观看视频 | 国产在线一 | wwww.8888久久爱站网 | 久久久久国产一级毛片高清网站 | 午夜精品福利视频 | 亚洲成人久久久 | 国内自拍偷拍视频 | 日韩精品一区二区三区视频播放 | 999久久久免费精品国产 | 国产精品永久免费 | 伊人网站在线 | 国产精品美女久久久久久久网站 | 精品欧美一区二区三区久久久 | 一区二区三区免费 | 国产成人一区二区三区精 | 国产精品精品视频一区二区三区 | 草逼网站| 网站国产 | 欧美11一13sex性hd | 成人福利网 | 香蕉二区| 免费久久久久久 | 亚洲一区二区免费 | 久久精品国产精品青草 | 亚洲精品一区二区冲田杏梨 | 欧美啊v在线观看 | 天天射色综合 | 欧美精品久久一区 | 国产免费一区二区 | japanhdxxxx裸体 | 免费一区二区三区 | 亚洲久久一区 | 91视频一区二区三区 | 自拍第一页 | 亚洲国产一区在线 | 亚洲精品电影 | 一区二区三区四区av | 成人午夜在线 | 天天操天天射综合网 | 国产免费一区 | 国产成人精品一区二区 |