{"id":250,"date":"2020-06-12T13:40:04","date_gmt":"2020-06-12T05:40:04","guid":{"rendered":"http:\/\/www.gbase8.cn\/?p=250"},"modified":"2025-01-15T17:29:54","modified_gmt":"2025-01-15T09:29:54","slug":"gbase-8a%e9%9b%86%e7%be%a4%e4%b8%ad%e6%95%b0%e7%9a%84%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/www.gbase8.cn\/en\/250","title":{"rendered":"\u5357\u5927\u901a\u7528GBase 8a\u96c6\u7fa4\u4e2d\u6570\u3001\u4e2d\u4f4d\u6570\u7684\u5b9e\u73b0"},"content":{"rendered":"<p>GBase 8a\u96c6\u7fa4\u4e2d\u6570\u7684\u5b9e\u73b0\u3002<\/p>\n\n\n\n<p>\u5bf9\u4e8e9.5.3.28\u65b0\u7248\u672c\uff0c\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b\u529f\u80fd\u5b9e\u73b0<\/p>\n\n\n\n<p><a href=\"https:\/\/www.gbase8.cn\/en\/12961\/?hilite=%E4%B8%AD%E4%BD%8D%E6%95%B0\">GBase 8a\u96c6\u7fa4\u767e\u5206\u4f4d\u51fd\u6570percentile_cont\u548cpercentile_disc\u4ecb\u7ecd<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u539f\u59cb\u6570\u636e\uff0c id3\u662f\u5206\u7ec4\u3002<br>gbase&gt; select * from testled;<br>+------+------+------+<br>| id | id2 | id3 |<br>+------+------+------+<br>| 1 | 111 | 1 |<br>| 2 | 110 | 0 |<br>| 3 | 109 | 0 |<br>| 4 | 108 | 1 |<br>| 5 | 107 | 0 |<br>| 6 | 106 | 0 |<br>| 7 | 105 | 1 |<br>| 8 | 104 | 0 |<br>+------+------+------+<br>8 rows in set (Elapsed: 00:00:00.00)<\/p>\n\n\n\n<p>\u7ed9\u6bcf\u4e00\u5217\uff0c\u6bcf\u4e00\u884c\u505a\u6392\u5e8f\u540e\u7684\u884c\u53f7\u3002<br>gbase&gt; select<br>-&gt; id,<br>-&gt; row_number()over(partition by id3 order by id) num_id,<br>-&gt; id2,<br>-&gt; row_number() over(partition by id3 order by id2) num_id2,<br>-&gt; id3<br>-&gt; from testled;<br>+------+--------+------+---------+------+<br>| id | num_id | id2 | num_id2 | id3 |<br>+------+--------+------+---------+------+<br>| 8 | 5 | 104 | 1 | 0 |<br>| 6 | 4 | 106 | 2 | 0 |<br>| 5 | 3 | 107 | 3 | 0 |<br>| 3 | 2 | 109 | 4 | 0 |<br>| 2 | 1 | 110 | 5 | 0 |<br>| 7 | 3 | 105 | 1 | 1 |<br>| 4 | 2 | 108 | 2 | 1 |<br>| 1 | 1 | 111 | 3 | 1 |<br>+------+--------+------+---------+------+<br>8 rows in set (Elapsed: 00:00:00.03)<\/p>\n\n\n\n<p>\u8ba1\u7b97\u6bcf\u4e00\u4e2a\u5217\u7684\u4e00\u534a\u884c\u53f7<br>gbase&gt; select *,<br>-&gt; ceil((max(num_id)over(partition by id3) +1)\/2) half_num_id,<br>-&gt; ceil((max(num_id2)over(partition by id3)+1)\/2) half_num_id2<br>-&gt; from (<br>-&gt; select<br>-&gt; id,<br>-&gt; row_number()over(partition by id3 order by id) num_id,<br>-&gt; id2,<br>-&gt; row_number() over(partition by id3 order by id2) num_id2,<br>-&gt; id3<br>-&gt; from testled<br>-&gt; )t ;<br>+------+--------+------+---------+------+-------------+--------------+<br>| id | num_id | id2 | num_id2 | id3 | half_num_id | half_num_id2 |<br>+------+--------+------+---------+------+-------------+--------------+<br>| 6 | 4 | 106 | 2 | 0 | 3 | 3 |<br>| 5 | 3 | 107 | 3 | 0 | 3 | 3 |<br>| 3 | 2 | 109 | 4 | 0 | 3 | 3 |<br>| 2 | 1 | 110 | 5 | 0 | 3 | 3 |<br>| 8 | 5 | 104 | 1 | 0 | 3 | 3 |<br>| 4 | 2 | 108 | 2 | 1 | 2 | 2 |<br>| 1 | 1 | 111 | 3 | 1 | 2 | 2 |<br>| 7 | 3 | 105 | 1 | 1 | 2 | 2 |<br>+------+--------+------+---------+------+-------------+--------------+<br>8 rows in set (Elapsed: 00:00:00.31)<\/p>\n\n\n\n<p><p>\u5b8c\u6574\u8ba1\u7b97\u3002\u6bcf\u4e2a\u5217\u7684\u4e2d\u6570<\/p>\n<pre class=\"wp-block-preformatted\">gbase&gt;  select\n    -&gt;    max(case when num_id=half_num_id then id else null end) over(partition by id3) id,\n    -&gt;    max(case when num_id2=half_num_id2 then id2 else null end) over (partition by id3) id2,\n    -&gt;    id3\n    -&gt;  from (\n    -&gt;    select *,\n    -&gt;      ceil((max(num_id)over(partition by id3) +1)\/2) half_num_id, \n    -&gt;      ceil((max(num_id2)over(partition by id3)+1)\/2) half_num_id2 \n    -&gt;    from (\n    -&gt;      select\n    -&gt;        id,\n    -&gt;        row_number()over(partition by id3 order by id) num_id,\n    -&gt;        id2,\n    -&gt;        row_number() over(partition by id3 order by id2) num_id2,\n    -&gt;        id3\n    -&gt;      from testled\n    -&gt;    )t\n    -&gt; )tt where num_id=half_num_id or num_id2=half_num_id2;\n+------+------+------+\n| id   | id2  | id3  |\n+------+------+------+\n|    5 |  107 |    0 |\n|    4 |  108 |    1 |\n+------+------+------+\n2 rows in set (Elapsed: 00:00:00.03)\n<\/pre><\/p>\n\n\n\n<p>\u4e24\u4e2a\u5217\u7684<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">select \n   max(case when num_id=half_num_id then id else null end) over(partition by id3) id, \n   max(case when num_id2=half_num_id2 then id2 else null end) over (partition by id3) id2, \n   id3\n from (\n   select *,\n     ceil((max(num_id)over(partition by id3) +1)\/2) half_num_id, \n     ceil((max(num_id2)over(partition by id3)+1)\/2) half_num_id2 \n   from (\n     select \n       id,\n       row_number()over(partition by id3 order by id) num_id,\n       id2,\n       row_number() over(partition by id3 order by id2) num_id2,\n       id3     \n     from testled\n   )t \n)tt where num_id=half_num_id or num_id2=half_num_id2;\n<\/pre>","protected":false},"excerpt":{"rendered":"<p>\u5357\u5927\u901a\u7528GBase 8a\u96c6\u7fa4\u4e2d\u6570\u3001\u4e2d\u4f4d\u6570\u7684\u5b9e\u73b0<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-250","post","type-post","status-publish","format-standard","hentry","category-gbase8a"],"_links":{"self":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/250","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/comments?post=250"}],"version-history":[{"count":12,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/250\/revisions"}],"predecessor-version":[{"id":12963,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/250\/revisions\/12963"}],"wp:attachment":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/media?parent=250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/categories?post=250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/tags?post=250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}