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

<legend id='vrqWF'><style id='vrqWF'><dir id='vrqWF'><q id='vrqWF'></q></dir></style></legend>

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

      1. Oracle:如何“分组"超过一个范围?

        Oracle: how to quot;group byquot; over a range?(Oracle:如何“分组超过一个范围?)
        <i id='zh0EY'><tr id='zh0EY'><dt id='zh0EY'><q id='zh0EY'><span id='zh0EY'><b id='zh0EY'><form id='zh0EY'><ins id='zh0EY'></ins><ul id='zh0EY'></ul><sub id='zh0EY'></sub></form><legend id='zh0EY'></legend><bdo id='zh0EY'><pre id='zh0EY'><center id='zh0EY'></center></pre></bdo></b><th id='zh0EY'></th></span></q></dt></tr></i><div id='zh0EY'><tfoot id='zh0EY'></tfoot><dl id='zh0EY'><fieldset id='zh0EY'></fieldset></dl></div>
        <legend id='zh0EY'><style id='zh0EY'><dir id='zh0EY'><q id='zh0EY'></q></dir></style></legend>
        • <bdo id='zh0EY'></bdo><ul id='zh0EY'></ul>

            <tfoot id='zh0EY'></tfoot>

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

                    <tbody id='zh0EY'></tbody>

                • 本文介绍了Oracle:如何“分组"超过一个范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如果我有一张这样的桌子:

                  If I have a table like this:

                  pkey   age
                  ----   ---
                     1     8
                     2     5
                     3    12
                     4    12
                     5    22
                  

                  我可以分组"以获取每个年龄的计数.

                  I can "group by" to get a count of each age.

                  select age,count(*) n from tbl group by age;
                  age  n
                  ---  -
                    5  1
                    8  1
                   12  2
                   22  1
                  

                  我可以使用什么查询来按年龄范围分组?

                  What query can I use to group by age ranges?

                    age  n
                  -----  -
                   1-10  2
                  11-20  2
                  20+    1
                  

                  我在使用 10gR2,但我也对任何特定于 11g 的方法感兴趣.

                  I'm on 10gR2, but I'd be interested in any 11g-specific approaches as well.

                  推荐答案

                  SELECT CASE 
                           WHEN age <= 10 THEN '1-10' 
                           WHEN age <= 20 THEN '11-20' 
                           ELSE '21+' 
                         END AS age, 
                         COUNT(*) AS n
                  FROM age
                  GROUP BY CASE 
                             WHEN age <= 10 THEN '1-10' 
                             WHEN age <= 20 THEN '11-20' 
                             ELSE '21+' 
                           END
                  

                  这篇关于Oracle:如何“分组"超过一个范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to redirect the output of DBMS_OUTPUT.PUT_LINE to a file?(如何将 DBMS_OUTPUT.PUT_LINE 的输出重定向到文件?)
                  How do I get column datatype in Oracle with PL-SQL with low privileges?(如何使用低权限的 PL-SQL 在 Oracle 中获取列数据类型?)
                  Get a list of all functions and procedures in an Oracle database(获取 Oracle 数据库中所有函数和过程的列表)
                  Why cannot I create triggers on objects owned by SYS?(为什么我不能在 SYS 拥有的对象上创建触发器?)
                  Returning result even for elements in IN list that don#39;t exist in table(即使对于表中不存在的 IN 列表中的元素也返回结果)
                  Reset Sequence in oracle 11g(oracle 11g 中的重置序列)
                  <legend id='GOoxk'><style id='GOoxk'><dir id='GOoxk'><q id='GOoxk'></q></dir></style></legend>

                  1. <i id='GOoxk'><tr id='GOoxk'><dt id='GOoxk'><q id='GOoxk'><span id='GOoxk'><b id='GOoxk'><form id='GOoxk'><ins id='GOoxk'></ins><ul id='GOoxk'></ul><sub id='GOoxk'></sub></form><legend id='GOoxk'></legend><bdo id='GOoxk'><pre id='GOoxk'><center id='GOoxk'></center></pre></bdo></b><th id='GOoxk'></th></span></q></dt></tr></i><div id='GOoxk'><tfoot id='GOoxk'></tfoot><dl id='GOoxk'><fieldset id='GOoxk'></fieldset></dl></div>
                  2. <small id='GOoxk'></small><noframes id='GOoxk'>

                  3. <tfoot id='GOoxk'></tfoot>

                      • <bdo id='GOoxk'></bdo><ul id='GOoxk'></ul>

                            <tbody id='GOoxk'></tbody>