{"id":481,"date":"2021-10-06T17:09:17","date_gmt":"2021-10-06T09:09:17","guid":{"rendered":"https:\/\/www.dataisfun.cn\/?p=481"},"modified":"2021-12-13T15:49:32","modified_gmt":"2021-12-13T07:49:32","slug":"%e7%aa%97%e5%8f%a3%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/www.dataisfun.cn\/?p=481","title":{"rendered":"SQL-\u7a97\u53e3\u51fd\u6570"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\" style=\"font-size:12px\">\u7a97\u53e3\u51fd\u6570\u7684\u5e94\u7528\u975e\u5e38\u5e7f\u6cdb\uff0c\u6d89\u53ca\u8de8\u884c\u8ba1\u7b97\u7684\u90fd\u9700\u8981\u5e94\u7528\u7a97\u53e3\u51fd\u6570\u6765\u5b9e\u73b0\uff0c\u5bf9\u7a97\u53e3\u51fd\u6570\u7684\u638c\u63e1\u7a0b\u5ea6\u80fd\u591f\u4f53\u73b0\u4e00\u4e2a\u6570\u636e\u5206\u6790\u5e08\u7684\u53d6\u6570\u529f\u5e95\uff0c\u56e0\u6b64\uff0c\u672c\u6587\u603b\u7ed3\u4e00\u4e0b\u7a97\u53e3\u51fd\u6570\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:12px\">\u6211\u4eec\u5148\u6765\u770b\u4e00\u4e0b\u7a97\u53e3\u51fd\u6570\u7684\u5b9a\u4e49\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">--\u51fd\u6570\u5b9a\u4e49\nfunction(args) OVER ([PARTITION BY expression]  [ORDER BY expression [ASC|DESC]])\n\n\n--\u53d8\u79cd1\nfunction(args) OVER ()\n\n\n--\u53d8\u79cd2\nfunction(args) OVER (PARTITION BY expression)\n\n\n--\u53d8\u79cd3\nfunction(args) OVER (ORDER BY expression [ASC|DESC])\n\n\n--\u53d8\u79cd4\nfunction(args) OVER (PARTITION BY expression  ORDER BY expression [ASC|DESC])<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:12px\">\u4ece\u8bed\u6cd5\u5b9a\u4e49\u6765\u770b\uff0c\u51fd\u6570 + over () \u5c31\u6784\u6210\u4e86\u7a97\u53e3\u51fd\u6570\uff0c\u4f46\u8fd9\u91cc\u7684\u51fd\u6570\u5e76\u4e0d\u652f\u6301\u6240\u6709\u51fd\u6570\uff0c\u800c\u662f\u4ec5\u652f\u6301\u4e24\u7c7b\u51fd\u6570\uff0c\u5176\u4e00\u662f\u672c\u8eab\u5c5e\u4e8e\u7a97\u53e3\u51fd\u6570\u7684\uff0c\u5176\u4e8c\u662f\u805a\u5408\u51fd\u6570\u3002\u5b50\u8bed\u53e5PARTITION BY\u7528\u4e8e\u6307\u5b9a\u7a97\u53e3\u7684\u5206\u7ec4\u4f9d\u636e\uff0c\u5b50\u8bed\u53e5ORDER BY\u7528\u4e8e\u6307\u5b9a\u7a97\u53e3\u7684\u6392\u5e8f\u4f9d\u636e\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:12px\">\u4e0b\u9762\u6211\u4eec\u5c31\u5217\u4e3e\u4e0bPresto SQL\u5e38\u7528\u7684\u5929\u751f\u7684\u7a97\u53e3\u51fd\u6570\uff0c\u5929\u751f\u7684\u610f\u601d\u662f\u8fd9\u4e9b\u51fd\u6570\u5fc5\u987b\u6709 over \u7a97\u53e3\u624d\u884c\uff1a<\/p>\n\n\n\n<ul class=\"has-vivid-cyan-blue-color has-text-color wp-block-list\" style=\"font-size:14px\"><li><strong>row_number() \u2192 bigint<\/strong><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:11px\">\u8fd4\u56de\u5e8f\u5217\u53f7\uff0c\u5e38\u7528\u4e8e\u5206\u7ec4\u53bb\u91cd\u3002<\/p>\n\n\n\n<ul class=\"has-vivid-cyan-blue-color has-text-color wp-block-list\" style=\"font-size:14px\"><li><strong>rank() \u2192 bigint<\/strong><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:11px\">\u8fd4\u56de\u6392\u540d\uff0c\u6392\u540d\u53d6\u503c\u4e0d\u8fde\u7eed\u3002<\/p>\n\n\n\n<ul class=\"has-vivid-cyan-blue-color has-text-color wp-block-list\" style=\"font-size:14px\"><li><strong>dense_rank() \u2192 bigint<\/strong><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:11px\">\u8fd4\u56de\u6392\u540d\uff0c\u6392\u540d\u53d6\u503c\u8fde\u7eed\u3002<\/p>\n\n\n\n<ul class=\"has-vivid-cyan-blue-color has-text-color wp-block-list\" style=\"font-size:14px\"><li><strong>first_value(x) \u2192 [same as input]<\/strong><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:11px\">\u8fd4\u56de\u7b2c1\u4e2a\u503c\u3002<\/p>\n\n\n\n<ul class=\"has-vivid-cyan-blue-color has-text-color wp-block-list\" style=\"font-size:14px\"><li><strong>last_value(x) \u2192 [same as input]<\/strong><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:11px\">\u8fd4\u56de\u6700\u540e1\u4e2a\u503c\u3002<\/p>\n\n\n\n<ul class=\"has-vivid-cyan-blue-color has-text-color wp-block-list\" style=\"font-size:14px\"><li><strong>nth_value(x, offset) \u2192 [same as input]<\/strong><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:11px\">\u8fd4\u56de\u7b2cN\u4e2a\u503c\u3002<\/p>\n\n\n\n<ul class=\"has-vivid-cyan-blue-color has-text-color wp-block-list\" style=\"font-size:14px\"><li><strong>lag(x[, offset[, default_value]]) \u2192 [same as input]<\/strong><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:11px\">\u8fd4\u56de\u5f53\u524d\u884c\u7684\u524dN\u884c\u7684\u503c\uff0c\u9ed8\u8ba4 offset \u503c\u4e3a1\uff0c\u4e5f\u5c31\u662f\u9ed8\u8ba4\u53d6\u524d1\u4e2a\u503c\u3002<\/p>\n\n\n\n<ul class=\"has-vivid-cyan-blue-color has-text-color wp-block-list\" style=\"font-size:14px\"><li><strong>lead(x[, offset[, default_value]]) \u2192 [same as input]<\/strong><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:11px\">\u8fd4\u56de\u5f53\u524d\u884c\u7684\u540eN\u884c\u7684\u503c\uff0c\u9ed8\u8ba4 offset \u503c\u4e3a1\uff0c\u4e5f\u5c31\u662f\u9ed8\u8ba4\u53d6\u540e1\u4e2a\u503c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:12px\"><br><strong>\u5e94\u7528\u4e3e\u4f8b\u2192<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:12px\">\u5047\u8bbe\u6211\u4eec\u6709\u5982\u4e0b table1\uff0c\u5de6\u8fb9\u662f table1 \u539f\u59cb\u6570\u636e\uff0c\u4e3a\u4e86\u4fbf\u4e8e\u89c2\u5bdf\u4ee3\u7801\u7ed3\u679c\uff0c\u6211\u4eec\u5c06 table1 \u6392\u5e8f\u540e\u7684\u7ed3\u679c\u4e5f\u5c55\u793a\u51fa\u6765\uff0c\u5373\u53f3\u8fb9\u7684 table1_sorted\uff1a <\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65701.png\" alt=\"\" class=\"wp-image-516\" width=\"719\" height=\"357\" srcset=\"https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65701.png 1438w, https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65701-300x149.png 300w, https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65701-1024x508.png 1024w, https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65701-768x381.png 768w, https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65701-605x300.png 605w\" sizes=\"auto, (max-width: 719px) 100vw, 719px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:12px\"><strong>\u793a\u4f8b\u4ee3\u7801\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">select\n\tid,\n\tproduct,\n\ttime,\n\tamount,\n\n\trow_number() over (partition by id order by time) as row_num,\n\trank() over (order by amount) as rank_num,\n\tdense_rank() over (order by amount) as dense_rank_num,\n\n\tfirst_value(product) over (partition by id order by time) as first_product,\n\tlast_value(product) over (partition by id order by time) as last_product,\n\tnth_value(product, 1) over (partition by id order by time) as nth_product_1,\n\tnth_value(product, 2) over (partition by id order by time) as nth_product_2,\n\n\tlag(product) over (partition by id order by time) as lag_product_1,\n\tlag(product,3) over (partition by id order by time) as lag_product_3,\n\tlead(product) over (partition by id order by time) as lead_product_1,\n\tlead(product,3) over (partition by id order by time) as lead_product_3\nfrom table1\norder by 1,2,3,4;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:12px\"><strong>\u4ee3\u7801\u7ed3\u679c\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65702-1024x620.png\" alt=\"\" class=\"wp-image-517\" width=\"512\" height=\"310\" srcset=\"https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65702-1024x620.png 1024w, https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65702-300x182.png 300w, https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65702-768x465.png 768w, https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65702-496x300.png 496w, https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65702.png 1135w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65703-1024x517.png\" alt=\"\" class=\"wp-image-518\" width=\"512\" height=\"259\" srcset=\"https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65703-1024x517.png 1024w, https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65703-300x151.png 300w, https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65703-768x387.png 768w, https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65703-595x300.png 595w, https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65703.png 1362w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65704-1024x494.png\" alt=\"\" class=\"wp-image-519\" width=\"512\" height=\"247\" srcset=\"https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65704-1024x494.png 1024w, https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65704-300x145.png 300w, https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65704-768x371.png 768w, https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65704-621x300.png 621w, https:\/\/www.dataisfun.cn\/wp-content\/uploads\/2021\/10\/\u7a97\u53e3\u51fd\u65704.png 1423w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:12px\"><br>\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u53ef\u6309\u9700\u4f7f\u7528 PARTITION BY\u3001ORDER BY [ASC | DESC]\u3001IGNORE NULLS\uff0c \u800c\u4e14\u9664\u4e86\u4ee5\u4e0a\u5929\u751f\u7684\u7a97\u53e3\u51fd\u6570\u5916\uff0c\u7a97\u53e3\u51fd\u6570\u8fd8\u652f\u6301\u805a\u5408\u51fd\u6570\uff0c\u5305\u62ec\uff1acount()\u3001count_if()\u3001sum()\u3001avg()\u3001 array_agg()\u3001 map_agg() \u7b49\u7b49\uff0c\u6211\u4eec\u53ef\u6309\u9700\u7ec4\u5408\u4f7f\u7528\u8fd9\u4e9b\u51fd\u6570\u3002 <\/p>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:12px\"><br><span class=\"sme-text-color has-cyan-bluish-gray-color\">\u539f\u521b\u6587\u7ae0\uff0c\u6b22\u8fce\u8f6c\u8f7d\uff0c\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\u5e76\u7559\u4e0b\u539f\u6587\u94fe\u63a5\u3002<\/span>  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7a97\u53e3\u51fd\u6570\u7684\u5e94\u7528\u975e\u5e38\u5e7f\u6cdb\uff0c\u6d89\u53ca\u8de8\u884c\u8ba1\u7b97\u7684\u90fd\u9700\u8981\u5e94\u7528\u7a97\u53e3\u51fd\u6570\u6765\u5b9e\u73b0\uff0c\u5bf9\u7a97\u53e3\u51fd\u6570\u7684\u638c\u63e1\u7a0b\u5ea6\u80fd\u591f\u4f53\u73b0\u4e00\u4e2a\u6570\u636e&hellip; <a href=\"https:\/\/www.dataisfun.cn\/?p=481\" class=\"more-link read-more\" rel=\"bookmark\">\u7ee7\u7eed\u9605\u8bfb <span class=\"screen-reader-text\">SQL-\u7a97\u53e3\u51fd\u6570<\/span><i class=\"fa fa-arrow-right\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[9,6],"class_list":["post-481","post","type-post","status-publish","format-standard","hentry","category-sql","tag-presto","tag-sql","h-entry","h-as-article"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.11 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u7a97\u53e3\u51fd\u6570 | SQL \u7a97\u53e3\u51fd\u6570 | Presto SQL \u7a97\u53e3\u51fd\u6570 - \u6570\u636e\u597d\u73a9<\/title>\n<meta name=\"description\" content=\"\u7a97\u53e3\u51fd\u6570\u7684\u5e94\u7528\u975e\u5e38\u5e7f\u6cdb\uff0c\u6d89\u53ca\u8de8\u884c\u8ba1\u7b97\u7684\u90fd\u9700\u8981\u5e94\u7528\u7a97\u53e3\u51fd\u6570\u6765\u5b9e\u73b0\uff0c\u5bf9\u7a97\u53e3\u51fd\u6570\u7684\u638c\u63e1\u7a0b\u5ea6\u80fd\u591f\u4f53\u73b0\u4e00\u4e2a\u6570\u636e\u5206\u6790\u5e08\u7684\u53d6\u6570\u529f\u5e95\uff0c\u56e0\u6b64\uff0c\u672c\u6587\u603b\u7ed3\u4e00\u4e0b\u7a97\u53e3\u51fd\u6570\u3002\u4ece\u8bed\u6cd5\u5b9a\u4e49\u6765\u770b\uff0c\u5b50\u8bed\u53e5PARTITION BY\u7528\u4e8e\u6307\u5b9a\u7a97\u53e3\u7684\u5206\u7ec4\u4f9d\u636e\uff0c\u5b50\u8bed\u53e5ORDER BY\u7528\u4e8e\u6307\u5b9a\u7a97\u53e3\u7684\u6392\u5e8f\u4f9d\u636e\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dataisfun.cn\/?p=481\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u7a97\u53e3\u51fd\u6570 | SQL \u7a97\u53e3\u51fd\u6570 | Presto SQL \u7a97\u53e3\u51fd\u6570 - \u6570\u636e\u597d\u73a9\" \/>\n<meta property=\"og:description\" content=\"\u7a97\u53e3\u51fd\u6570\u7684\u5e94\u7528\u975e\u5e38\u5e7f\u6cdb\uff0c\u6d89\u53ca\u8de8\u884c\u8ba1\u7b97\u7684\u90fd\u9700\u8981\u5e94\u7528\u7a97\u53e3\u51fd\u6570\u6765\u5b9e\u73b0\uff0c\u5bf9\u7a97\u53e3\u51fd\u6570\u7684\u638c\u63e1\u7a0b\u5ea6\u80fd\u591f\u4f53\u73b0\u4e00\u4e2a\u6570\u636e\u5206\u6790\u5e08\u7684\u53d6\u6570\u529f\u5e95\uff0c\u56e0\u6b64\uff0c\u672c\u6587\u603b\u7ed3\u4e00\u4e0b\u7a97\u53e3\u51fd\u6570\u3002\u4ece\u8bed\u6cd5\u5b9a\u4e49\u6765\u770b\uff0c\u5b50\u8bed\u53e5PARTITION BY\u7528\u4e8e\u6307\u5b9a\u7a97\u53e3\u7684\u5206\u7ec4\u4f9d\u636e\uff0c\u5b50\u8bed\u53e5ORDER BY\u7528\u4e8e\u6307\u5b9a\u7a97\u53e3\u7684\u6392\u5e8f\u4f9d\u636e\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dataisfun.cn\/?p=481\" \/>\n<meta property=\"og:site_name\" content=\"\u6570\u636e\u597d\u73a9\" \/>\n<meta property=\"article:published_time\" content=\"2021-10-06T09:09:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-12-13T07:49:32+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dataisfun.cn\/?p=481\",\"url\":\"https:\/\/www.dataisfun.cn\/?p=481\",\"name\":\"\u7a97\u53e3\u51fd\u6570 | SQL \u7a97\u53e3\u51fd\u6570 | Presto SQL \u7a97\u53e3\u51fd\u6570 - \u6570\u636e\u597d\u73a9\",\"isPartOf\":{\"@id\":\"https:\/\/www.dataisfun.cn\/#website\"},\"datePublished\":\"2021-10-06T09:09:17+00:00\",\"dateModified\":\"2021-12-13T07:49:32+00:00\",\"author\":{\"@id\":\"https:\/\/www.dataisfun.cn\/#\/schema\/person\/026bc03694bbf1608ccc639fb31c3293\"},\"description\":\"\u7a97\u53e3\u51fd\u6570\u7684\u5e94\u7528\u975e\u5e38\u5e7f\u6cdb\uff0c\u6d89\u53ca\u8de8\u884c\u8ba1\u7b97\u7684\u90fd\u9700\u8981\u5e94\u7528\u7a97\u53e3\u51fd\u6570\u6765\u5b9e\u73b0\uff0c\u5bf9\u7a97\u53e3\u51fd\u6570\u7684\u638c\u63e1\u7a0b\u5ea6\u80fd\u591f\u4f53\u73b0\u4e00\u4e2a\u6570\u636e\u5206\u6790\u5e08\u7684\u53d6\u6570\u529f\u5e95\uff0c\u56e0\u6b64\uff0c\u672c\u6587\u603b\u7ed3\u4e00\u4e0b\u7a97\u53e3\u51fd\u6570\u3002\u4ece\u8bed\u6cd5\u5b9a\u4e49\u6765\u770b\uff0c\u5b50\u8bed\u53e5PARTITION BY\u7528\u4e8e\u6307\u5b9a\u7a97\u53e3\u7684\u5206\u7ec4\u4f9d\u636e\uff0c\u5b50\u8bed\u53e5ORDER BY\u7528\u4e8e\u6307\u5b9a\u7a97\u53e3\u7684\u6392\u5e8f\u4f9d\u636e\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/www.dataisfun.cn\/?p=481#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dataisfun.cn\/?p=481\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dataisfun.cn\/?p=481#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.dataisfun.cn\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL-\u7a97\u53e3\u51fd\u6570\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dataisfun.cn\/#website\",\"url\":\"https:\/\/www.dataisfun.cn\/\",\"name\":\"\u6570\u636e\u597d\u73a9\",\"description\":\"\u6570\u4e2d\u81ea\u6709\u4e7e\u5764\uff0c\u4e8e\u4e50\u8da3\u4e2d\u53d1\u73b0\u4ef7\u503c\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dataisfun.cn\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.dataisfun.cn\/#\/schema\/person\/026bc03694bbf1608ccc639fb31c3293\",\"name\":\"admin\",\"sameAs\":[\"http:\/\/www.dataisfun.cn\"],\"url\":\"https:\/\/www.dataisfun.cn\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u7a97\u53e3\u51fd\u6570 | SQL \u7a97\u53e3\u51fd\u6570 | Presto SQL \u7a97\u53e3\u51fd\u6570 - \u6570\u636e\u597d\u73a9","description":"\u7a97\u53e3\u51fd\u6570\u7684\u5e94\u7528\u975e\u5e38\u5e7f\u6cdb\uff0c\u6d89\u53ca\u8de8\u884c\u8ba1\u7b97\u7684\u90fd\u9700\u8981\u5e94\u7528\u7a97\u53e3\u51fd\u6570\u6765\u5b9e\u73b0\uff0c\u5bf9\u7a97\u53e3\u51fd\u6570\u7684\u638c\u63e1\u7a0b\u5ea6\u80fd\u591f\u4f53\u73b0\u4e00\u4e2a\u6570\u636e\u5206\u6790\u5e08\u7684\u53d6\u6570\u529f\u5e95\uff0c\u56e0\u6b64\uff0c\u672c\u6587\u603b\u7ed3\u4e00\u4e0b\u7a97\u53e3\u51fd\u6570\u3002\u4ece\u8bed\u6cd5\u5b9a\u4e49\u6765\u770b\uff0c\u5b50\u8bed\u53e5PARTITION BY\u7528\u4e8e\u6307\u5b9a\u7a97\u53e3\u7684\u5206\u7ec4\u4f9d\u636e\uff0c\u5b50\u8bed\u53e5ORDER BY\u7528\u4e8e\u6307\u5b9a\u7a97\u53e3\u7684\u6392\u5e8f\u4f9d\u636e\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dataisfun.cn\/?p=481","og_locale":"zh_CN","og_type":"article","og_title":"\u7a97\u53e3\u51fd\u6570 | SQL \u7a97\u53e3\u51fd\u6570 | Presto SQL \u7a97\u53e3\u51fd\u6570 - \u6570\u636e\u597d\u73a9","og_description":"\u7a97\u53e3\u51fd\u6570\u7684\u5e94\u7528\u975e\u5e38\u5e7f\u6cdb\uff0c\u6d89\u53ca\u8de8\u884c\u8ba1\u7b97\u7684\u90fd\u9700\u8981\u5e94\u7528\u7a97\u53e3\u51fd\u6570\u6765\u5b9e\u73b0\uff0c\u5bf9\u7a97\u53e3\u51fd\u6570\u7684\u638c\u63e1\u7a0b\u5ea6\u80fd\u591f\u4f53\u73b0\u4e00\u4e2a\u6570\u636e\u5206\u6790\u5e08\u7684\u53d6\u6570\u529f\u5e95\uff0c\u56e0\u6b64\uff0c\u672c\u6587\u603b\u7ed3\u4e00\u4e0b\u7a97\u53e3\u51fd\u6570\u3002\u4ece\u8bed\u6cd5\u5b9a\u4e49\u6765\u770b\uff0c\u5b50\u8bed\u53e5PARTITION BY\u7528\u4e8e\u6307\u5b9a\u7a97\u53e3\u7684\u5206\u7ec4\u4f9d\u636e\uff0c\u5b50\u8bed\u53e5ORDER BY\u7528\u4e8e\u6307\u5b9a\u7a97\u53e3\u7684\u6392\u5e8f\u4f9d\u636e\u3002","og_url":"https:\/\/www.dataisfun.cn\/?p=481","og_site_name":"\u6570\u636e\u597d\u73a9","article_published_time":"2021-10-06T09:09:17+00:00","article_modified_time":"2021-12-13T07:49:32+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.dataisfun.cn\/?p=481","url":"https:\/\/www.dataisfun.cn\/?p=481","name":"\u7a97\u53e3\u51fd\u6570 | SQL \u7a97\u53e3\u51fd\u6570 | Presto SQL \u7a97\u53e3\u51fd\u6570 - \u6570\u636e\u597d\u73a9","isPartOf":{"@id":"https:\/\/www.dataisfun.cn\/#website"},"datePublished":"2021-10-06T09:09:17+00:00","dateModified":"2021-12-13T07:49:32+00:00","author":{"@id":"https:\/\/www.dataisfun.cn\/#\/schema\/person\/026bc03694bbf1608ccc639fb31c3293"},"description":"\u7a97\u53e3\u51fd\u6570\u7684\u5e94\u7528\u975e\u5e38\u5e7f\u6cdb\uff0c\u6d89\u53ca\u8de8\u884c\u8ba1\u7b97\u7684\u90fd\u9700\u8981\u5e94\u7528\u7a97\u53e3\u51fd\u6570\u6765\u5b9e\u73b0\uff0c\u5bf9\u7a97\u53e3\u51fd\u6570\u7684\u638c\u63e1\u7a0b\u5ea6\u80fd\u591f\u4f53\u73b0\u4e00\u4e2a\u6570\u636e\u5206\u6790\u5e08\u7684\u53d6\u6570\u529f\u5e95\uff0c\u56e0\u6b64\uff0c\u672c\u6587\u603b\u7ed3\u4e00\u4e0b\u7a97\u53e3\u51fd\u6570\u3002\u4ece\u8bed\u6cd5\u5b9a\u4e49\u6765\u770b\uff0c\u5b50\u8bed\u53e5PARTITION BY\u7528\u4e8e\u6307\u5b9a\u7a97\u53e3\u7684\u5206\u7ec4\u4f9d\u636e\uff0c\u5b50\u8bed\u53e5ORDER BY\u7528\u4e8e\u6307\u5b9a\u7a97\u53e3\u7684\u6392\u5e8f\u4f9d\u636e\u3002","breadcrumb":{"@id":"https:\/\/www.dataisfun.cn\/?p=481#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dataisfun.cn\/?p=481"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dataisfun.cn\/?p=481#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.dataisfun.cn\/"},{"@type":"ListItem","position":2,"name":"SQL-\u7a97\u53e3\u51fd\u6570"}]},{"@type":"WebSite","@id":"https:\/\/www.dataisfun.cn\/#website","url":"https:\/\/www.dataisfun.cn\/","name":"\u6570\u636e\u597d\u73a9","description":"\u6570\u4e2d\u81ea\u6709\u4e7e\u5764\uff0c\u4e8e\u4e50\u8da3\u4e2d\u53d1\u73b0\u4ef7\u503c","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dataisfun.cn\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.dataisfun.cn\/#\/schema\/person\/026bc03694bbf1608ccc639fb31c3293","name":"admin","sameAs":["http:\/\/www.dataisfun.cn"],"url":"https:\/\/www.dataisfun.cn\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/www.dataisfun.cn\/index.php?rest_route=\/wp\/v2\/posts\/481","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dataisfun.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dataisfun.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dataisfun.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dataisfun.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=481"}],"version-history":[{"count":18,"href":"https:\/\/www.dataisfun.cn\/index.php?rest_route=\/wp\/v2\/posts\/481\/revisions"}],"predecessor-version":[{"id":777,"href":"https:\/\/www.dataisfun.cn\/index.php?rest_route=\/wp\/v2\/posts\/481\/revisions\/777"}],"wp:attachment":[{"href":"https:\/\/www.dataisfun.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dataisfun.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dataisfun.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}