<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:如何“分组"超过一个范围?

        时间:2023-11-02
        <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:如何“分组"超过一个范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何获取受存储过程影响的记录数? 下一篇:批量插入 Oracle 数据库:哪个更好:FOR Cursor 循环还是简单的 Select?

                  相关文章

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