假设我们有以下查询。
\nselect\n name,\n pos,\n rank() over (partition by constructor) r,\n format('%s / %s',\n row_number() over (partition by constructor),\n count(*) over (partition by constructor)\n ) "pos/global"\nfrom (values\n ('d1-c1', 1, 'c1'),\n ('d3-c1', 3, 'c1'),\n ('d3-c2', 3, 'c2'),\n ('d2-c1', 2, 'c1'),\n ('d2-c2', 2, 'c2')\n ) t(name, pos, constructor);\n
Run Code Online (Sandbox Code Playgroud)\n输出如下:
\n name \xe2\x94\x82 pos \xe2\x94\x82 r \xe2\x94\x82 pos/global\n\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\xaa\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\xaa\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\xaa\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\n d1-c1 \xe2\x94\x82 1 \xe2\x94\x82 1 \xe2\x94\x82 1 / 3\n d3-c1 \xe2\x94\x82 3 \xe2\x94\x82 1 \xe2\x94\x82 2 / 3\n d2-c1 \xe2\x94\x82 2 \xe2\x94\x82 1 \xe2\x94\x82 …
Run Code Online (Sandbox Code Playgroud)