{"id":6029,"date":"2018-11-22T21:12:20","date_gmt":"2018-11-23T05:12:20","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=6029"},"modified":"2025-06-13T20:19:54","modified_gmt":"2025-06-14T03:19:54","slug":"on-par-with-window-functions-in-n1ql","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/ko\/on-par-with-window-functions-in-n1ql\/","title":{"rendered":"\ucc3d \uae30\ub2a5\uacfc \ub3d9\ub4f1\ud55c \uc218\uc900."},"content":{"rendered":"<blockquote><p><span style=\"font-weight: 400\">\uacbd\uc601\uc9c4\uc5d0\uac8c \uc124\uba85\ud560 \ub54c\ub294 \uace8\ud504 \ube44\uc720\ub97c \uc0ac\uc6a9\ud558\uc138\uc694.<\/span><br \/>\n<span style=\"font-weight: 400\">\ub2e4\ub978 \ubaa8\ub4e0 \uac83\uc5d0\ub294 \uc790\ub3d9\ucc28 \ube44\uc720\ub97c \uc0ac\uc6a9\ud558\uc138\uc694.  - \uacf5\uc790. <\/span><\/p><\/blockquote>\n<p><span style=\"font-weight: 400\">\ucc3d \ud568\uc218\uc758 \ubaa9\uc801\uc740 \ube44\uc988\ub2c8\uc2a4 \ubcf4\uace0 \uc694\uad6c \uc0ac\ud56d\uc744 \uc120\uc5b8\uc801\uc73c\ub85c \ud6a8\uacfc\uc801\uc73c\ub85c SQL\ub85c \ubcc0\ud658\ud558\uc5ec \ucffc\ub9ac \uc131\ub2a5\uacfc \uac1c\ubc1c\uc790\/\ube44\uc988\ub2c8\uc2a4 \ubd84\uc11d\uac00\uc758 \ud6a8\uc728\uc131\uc744 \ud68d\uae30\uc801\uc73c\ub85c \uac1c\uc120\ud558\ub294 \uac83\uc785\ub2c8\ub2e4. \uc2e4\uc81c \ubcf4\uace0\uc11c\uc640 \ub300\uc2dc\ubcf4\ub4dc\uac00 \ucc3d \ud568\uc218\ub97c \uc0ac\uc6a9\ud55c \ud6c4 \uba87 \uc2dc\uac04\uc5d0\uc11c \uba87 \ubd84\uc73c\ub85c, \uba87 \ubd84\uc5d0\uc11c \uba87 \ucd08\ub85c \ub2e8\ucd95\ub418\ub294 \uac83\uc744 \ubcf4\uc558\uc2b5\ub2c8\ub2e4.  \ucffc\ub9ac \ud06c\uae30\uac00 40\ud398\uc774\uc9c0\uc5d0\uc11c \uba87 \ud398\uc774\uc9c0\ub85c \uc904\uc5b4\ub4ed\ub2c8\ub2e4. 90\ub144\ub300\uc5d0 Redbrick \ub370\uc774\ud130\ubca0\uc774\uc2a4\ub294 \ube44\uc988\ub2c8\uc2a4 \uc0ac\uc6a9 \uc0ac\ub840\ub97c \uc798 \uc774\ud574\ud558\uace0 \uc21c\uc704, \uc2e4\ud589 \ud569\uacc4, \ud558\uc704 \uadf8\ub8f9, \uc9c1\uc704 \ub4f1\uc744 \uae30\uc900\uc73c\ub85c \ucee4\ubbf8\uc158 \ubc0f \uc7ac\uace0 \uacc4\uc0b0 \ub4f1 \ube44\uc988\ub2c8\uc2a4 \ubcf4\uace0\ub97c \uc704\ud55c \uc0c8\ub85c\uc6b4 \uae30\ub2a5 \uacc4\uce35\uc744 \ub9cc\ub4e4\uc5c8\uc2b5\ub2c8\ub2e4. \uc774\ub7ec\ud55c \uae30\ub2a5\uc740 2003\ub144\ubd80\ud130 SQL \ud45c\uc900\uc5d0 \ud3ec\ud568\ub418\uc5c8\uc2b5\ub2c8\ub2e4.  \ubaa8\ub4e0 BI \uacc4\uce35(\uc608: Tableau, Looker, Cognos)\uc740 \uc774 \uae30\ub2a5\uc744 \ud65c\uc6a9\ud569\ub2c8\ub2e4.<\/span><\/p>\n<p><b>\ucc3d \uae30\ub2a5 \uc18c\uac1c<\/b><\/p>\n<p><span style=\"font-weight: 400\">\ub450 \ub77c\uc6b4\ub4dc\ub97c \ud1b5\ud574 6\uba85\uc758 \uace8\ud37c\uc758 \uc2a4\ucf54\uc5b4\uac00 \uc788\ub2e4\uace0 \uac00\uc815\ud574 \ubcf4\uaca0\uc2b5\ub2c8\ub2e4. \uc774\uc81c \ub9ac\ub354\ubcf4\ub4dc\ub97c \ub9cc\ub4e4\uc5b4 \uc21c\uc704\ub97c \ub9e4\uaca8\uc57c \ud569\ub2c8\ub2e4. SQL\uc744 \uc0ac\uc6a9\ud558\uc5ec \uc21c\uc704\ub97c \ub9e4\uae41\ub2c8\ub2e4.<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">\ud50c\ub808\uc774\uc5b4<\/span><\/td>\n<td><span style=\"font-weight: 400\">Round1<\/span><\/td>\n<td><span style=\"font-weight: 400\">Round2<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Marco<\/span><\/td>\n<td><span style=\"font-weight: 400\">75<\/span><\/td>\n<td><span style=\"font-weight: 400\">73<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Johan<\/span><\/td>\n<td><span style=\"font-weight: 400\">72<\/span><\/td>\n<td><span style=\"font-weight: 400\">68<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Chang<\/span><\/td>\n<td><span style=\"font-weight: 400\">67<\/span><\/td>\n<td><span style=\"font-weight: 400\">76<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Isha<\/span><\/td>\n<td><span style=\"font-weight: 400\">74<\/span><\/td>\n<td><span style=\"font-weight: 400\">71<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Sitaram<\/span><\/td>\n<td><span style=\"font-weight: 400\">68<\/span><\/td>\n<td><span style=\"font-weight: 400\">72<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">\ube59\uc9c0\uc5d0<\/span><\/td>\n<td><span style=\"font-weight: 400\">71<\/span><\/td>\n<td><span style=\"font-weight: 400\">67<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\uce74\uc6b0\uce58\ubca0\uc774\uc2a4\uc5d0 \ub370\uc774\ud130\ub97c \uc0bd\uc785\ud569\ub2c8\ub2e4.<\/p>\n<pre class=\"theme:github whitespace-before:2 whitespace-after:2 lang:plsql decode:true\" title=\"\uce74\uc6b0\uce58\ubca0\uc774\uc2a4\uc5d0 \ub370\uc774\ud130\ub97c \uc0bd\uc785\ud569\ub2c8\ub2e4.\">INSERT INTO golf \r\nVALUES(\"KP1\", {\"player\": \"Marco\", \"round1\":75, \"round2\":73}),\r\nVALUES(\"KP2\", {\"player\": \"Johan\", \"round1\":72, \"round2\":68}),\r\nVALUES(\"KP3\", {\"player\": \"Chang\", \"round1\":67, \"round2\":76}),\r\nVALUES(\"KP4\", {\"player\": \"Isha\", \"round1\":74, \"round2\":71}),\r\nVALUES(\"KP5\", {\"player\": \"Sitaram\", \"round1\":68, \"round2\":72}),\r\nVALUES(\"KP6\", {\"player\": \"Bingjie\", \"round1\":71, \"round2\":67});\r\n\r\n<\/pre>\n<p><span style=\"font-weight: 400;color: #0000ff\">\ucc3d \uae30\ub2a5 \uc5c6\uc74c(\ud604\uc7ac \uc0c1\ud0dc - Couchbase 6.0)<\/span><\/p>\n<p><span style=\"font-weight: 400\">\ucc3d \ud568\uc218\ub97c \uc0ac\uc6a9\ud558\uc9c0 \uc54a\uace0 \ucffc\ub9ac\ub97c \uc791\uc131\ud558\ub824\uba74 \uac01 \ud50c\ub808\uc774\uc5b4\uc758 \uc21c\uc704\ub97c \uacc4\uc0b0\ud558\ub294 \ud558\uc704 \ucffc\ub9ac\uac00 \ud544\uc694\ud569\ub2c8\ub2e4.  \uc774 \ud558\uc704 \ucffc\ub9ac\ub294 \ubaa8\ub4e0 \ub370\uc774\ud130\ub97c \uc2a4\uce94\ud574\uc57c \ud569\ub2c8\ub2e4.<\/span><span style=\"font-weight: 400\">\u00a0\uc758 \ucd5c\uc545\uc758 \uc54c\uace0\ub9ac\uc998 \ubcf5\uc7a1\uc131\uc744 \ucd08\ub798\ud569\ub2c8\ub2e4. <\/span><b>O(N^2), <\/b><span style=\"font-weight: 400\">\uc2e4\ud589 \uc2dc\uac04\uacfc \ucc98\ub9ac\ub7c9\uc774 \ud06c\uac8c \uc99d\uac00\ud569\ub2c8\ub2e4.<\/span><\/p>\n<pre class=\"theme:github whitespace-before:2 whitespace-after:2 lang:plsql decode:true\" title=\"\ucc3d \ud568\uc218\uac00 \uc5c6\ub294 RANK \ucffc\ub9ac\">WITH g1 as (select player, round1, round2 from golf)\r\nSELECT    g3.player                                AS player,\r\n          (g3.round1+g3.round2)                    AS T,\r\n          ((g3.round1+g3.round2) - 144)            AS ToPar, \r\n          (select raw 1+COUNT(*) \r\n             from g1 as g2 \r\n               where (g2.round1 + g2.round2) &lt; \r\n                     (g3.round1 + g3.round2))[0]   AS sqlrankR2\r\nFROM g1 as g3\r\nORDER BY sqlrankR2\r\n\r\nResults: \r\nT\tToPar\tplayer\tsqlrankR2\r\n138\t-6\t\"Bingjie\"    1\r\n140\t-4\t\"Johan\"      2\r\n140\t-4\t\"Sitaram\"    2\r\n143\t-1\t\"Chang\"      4\r\n145\t1\t\"Isha\"       5\r\n148\t4\t\"Marco\"      6\r\n<\/pre>\n<p><span style=\"font-weight: 400;color: #0000ff\">Mad-Hatter\uc758 \ucc3d \uae30\ub2a5 \uc0ac\uc6a9(\ucd9c\uc2dc \uc608\uc815)<\/span><\/p>\n<p><span style=\"font-weight: 400\">\uc774 \ucffc\ub9ac\ub294 \ud50c\ub808\uc774\uc5b4, \ub450 \ub77c\uc6b4\ub4dc(T) \ud6c4 \ud569\uacc4, \uc2a4\ucf54\uc5b4\uc758 \uc624\ubc84\/\uc5b8\ub354\ud30c(ToPar) \ube44\uc728\uc744 \ubc18\ud658\ud569\ub2c8\ub2e4. <\/span><b>\uc21c\uc704<\/b> <span style=\"font-weight: 400\">\uccab \ub450 \ub77c\uc6b4\ub4dc\uc758 \uc810\uc218\ub97c \uae30\uc900\uc73c\ub85c \uc810\uc218\ub97c \ub9e4\uae41\ub2c8\ub2e4.  \uc774\uac83\uc774 Mad-Hatter\uc758 \uc0c8\ub85c\uc6b4 \uae30\ub2a5\uc785\ub2c8\ub2e4. \uc774 \uae30\ub2a5\uc758 \uc2dc\uac04 \ubcf5\uc7a1\ub3c4\ub294 O(N)\uc774\ubbc0\ub85c \uc2e4\ud589 \uc2dc\uac04\uc774 \uc120\ud615\uc801\uc73c\ub85c\ub9cc \uc99d\uac00\ud569\ub2c8\ub2e4. \u00a0<\/span><\/p>\n<pre class=\"theme:github tab-size:2 whitespace-before:2 whitespace-after:2 lang:plsql decode:true\" title=\"\ucc3d \ud568\uc218 RANK()\ub97c \uc0ac\uc6a9\ud55c \uc21c\uc704 \ucffc\ub9ac.\">SELECT    player                                AS player,\r\n          (round1+round2)                       AS T,\r\n          ((round1+round2) - 144)               AS ToPar,\r\n          RANK() OVER(ORDER BY (round1+round2)) AS rankR2\r\nFROM golf;\r\n\r\n\r\nT\tToPar\tplayer\t   rankR2\r\n138\t-6\t\"Bingjie\"    1\r\n140\t-4\t\"Johan\"      2\r\n140\t-4\t\"Sitaram\"    2\r\n143\t-1\t\"Chang\"      4\r\n145\t 1\t \"Isha\"      5\r\n148\t4\t\"Marco\"      6\r\n<\/pre>\n<p><b>\uad00\ucc30:<\/b><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\uc774 \ucffc\ub9ac\ub294 \uc694\uad6c \uc0ac\ud56d\uc744 \uac04\ub2e8\ud558\uace0 \uba85\ud655\ud558\uac8c \ud45c\ud604\ud569\ub2c8\ub2e4.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\uc2e4\uc81c \uc2dc\ub098\ub9ac\uc624\uc5d0\uc11c \uc774 \ucffc\ub9ac\uc758 \uc131\ub2a5\uc740 \ud6e8\uc52c \ub354 \uc88b\uc2b5\ub2c8\ub2e4.  \uce21\uc815\ud560 \uacc4\ud68d\uc785\ub2c8\ub2e4.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\uc21c\uc704 \uc694\uad6c \uc0ac\ud56d\uc774 \uc5ec\ub7ec \ubb38\uc11c\uc5d0 \ub530\ub77c \ub2ec\ub77c\uc9c0\ub294 \uacbd\uc6b0 \ucffc\ub9ac \uc791\uc131, \ucd5c\uc801\ud654 \ubc0f \uc2e4\ud589\uc774 \ub9e4\uc6b0 \ubcf5\uc7a1\ud574\uc9d1\ub2c8\ub2e4.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\uc774 \ubaa8\ub4e0 \uac83\uc774 \uc804\uccb4 TCO\uc5d0 \uc601\ud5a5\uc744 \ubbf8\uce69\ub2c8\ub2e4.<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">\uc774\uc81c \ud655\uc7a5\ub41c \ub300\uc2dc\ubcf4\ub4dc\ub97c \ub9cc\ub4e4\uc5b4 \ubcf4\uaca0\uc2b5\ub2c8\ub2e4.<\/span><\/p>\n<p><span style=\"font-weight: 400\">\ubc00\ub3c4 \ucd94\uac00 \uc21c\uc704, \ud589 \ubc88\ud638, \uc120\ub450\uc790, \uc120\ub450\uc790 \ub4a4\uc5d0 \uc788\ub294 \uc2a4\ud2b8\ub85c\ud06c \uc218\ub97c \ud45c\uc2dc\ud569\ub2c8\ub2e4.  \ubaa8\ub450 \ubcf4\uace0 \ub9ac\ud3ec\uc9c0\uc154\ub2dd\uc5d0\uc11c \ub9e4\uc6b0 \uc77c\ubc18\uc801\uc778 \uac83\ub4e4\uc785\ub2c8\ub2e4. OVER() \uc808\uc774 \ubcf4\uc77c \ub54c\ub9c8\ub2e4 \uc0c8 \ucc3d \ud568\uc218\uac00 \ud45c\uc2dc\ub429\ub2c8\ub2e4.  \uc544\ub798 \ucffc\ub9ac\uc5d0\ub294 6\uac1c\uc758 \ucc3d \ud568\uc218\uac00 \uc788\uc2b5\ub2c8\ub2e4. <\/span><\/p>\n<pre class=\"theme:github whitespace-before:2 whitespace-after:2 lang:plsql decode:true\">SELECT    player                                AS player,\r\n          (round1+round2)                       AS T,\r\n          ((round1+round2) - 144)               AS ToPar,\r\n          RANK() OVER(ORDER BY (round1+round2)) AS rankR2,\r\n          DENSE_RANK() OVER (ORDER BY (round1+round2)) AS rankR2Dense,\r\n          ROW_NUMBER() OVER() rownum,\r\n          ((round1+round2) - \r\n              FIRST_VALUE(round1+round2) \r\n                OVER(ORDER BY (round1+round2))) AS strokesbehind,\r\n          RANK() OVER(ORDER BY (round1))        AS rankR1,\r\n          LAG(player, 1, \"None\") OVER(ORDER BY round1+round2) \r\n                                                AS inFront\r\nFROM golf\r\nORDER BY rankR2\r\n\r\n\r\nT\tToPar\tinFront\t  player    rankR1  rankR2 rankR2Dense rownum strokesbehind\r\n138\t-6\t\"None\"    \"Bingjie\"\t3\t1\t1\t3\t0\r\n140\t-4\t\"Johan\"\t  \"Sitaram\"\t2\t2\t2\t2\t2\r\n140\t-4\t\"Bingjie\" \"Johan\"\t4\t2\t2\t4\t2\r\n143\t-1\t\"Sitaram\" \"Chang\"\t1\t4\t3\t1\t5\r\n145\t 1\t \"Chang\"  \"Isha\"        5\t5\t4\t5\t7\r\n148\t 4\t\"Isha\"\t  \"Marco\"\t6\t6\t5\t6\t10\r\n<\/pre>\n<p><span style=\"font-weight: 400\">\uc55e\uc11c \ubcf4\uc558\ub4ef\uc774 \uc774 \ucffc\ub9ac\ub97c \uc218\ud589\ud558\ub824\uba74 <\/span><b>\ub2e4\uc74c\uc744 \uc0ac\uc6a9\ud558\ub294 6\uac00\uc9c0 \ucc3d \uae30\ub2a5<\/b><span style=\"font-weight: 400\"> \ud558\uc704 \ucffc\ub9ac \ubc29\ubc95\uc740 \ub354 \ub9ce\uc740 \ub178\ub825\uc774 \ud544\uc694\ud558\uace0 \ube44\uc6a9\uc774 \ub9ce\uc774 \ub4e4\uba70 \uc624\ub958\uac00 \ubc1c\uc0dd\ud558\uae30 \uc26c\uc6b4 \ucffc\ub9ac\uc785\ub2c8\ub2e4.<\/span><\/p>\n<p><span style=\"font-weight: 400\">\uae30\ubcf8 \uc81c\uacf5 \uc9d1\uacc4(COUNT, SUM, AVG \ub4f1)\ub97c \ucc3d \ud568\uc218\ub85c \ub9cc\ub4dc\ub294 \uac83 \uc678\uc5d0\ub3c4 Sitaram\uc740 \ub2e4\uc74c\uacfc \uac19\uc740 \ucc3d \ud568\uc218\ub97c \ucd94\uac00\ud588\uc2b5\ub2c8\ub2e4.  \uac01\uac01\uc758 \uad6c\ubb38\uacfc \uc758\ubbf8\ub294 \ud45c\uc900\uc5d0 \uc798 \uc815\uc758\ub418\uc5b4 \uc788\uc73c\uba70 \uc544\ub798 \ucc38\uc870 \uc139\uc158\uc758 \ubb38\uc11c\uc5d0 \uc798 \uc124\uba85\ub418\uc5b4 \uc788\uc2b5\ub2c8\ub2e4.<\/span><\/p>\n<p><b>RANK()<\/b><b><br \/>\n<\/b><b>DENSE_RANK()<\/b><b><br \/>\n<\/b><b>PERCENT_RANK()<\/b><b><br \/>\n<\/b><b>CUME_DIST()<\/b><b><br \/>\n<\/b><b>NTILE()<\/b><b><br \/>\n<\/b><b>ratio_to_report()<\/b><b><br \/>\n<\/b><b>ROW_NUMBER()<\/b><b><br \/>\n<\/b><b>LAG()<\/b><b><br \/>\n<\/b><b>FIRST_VALUE()<\/b><b><br \/>\n<\/b><b>LAST_VALUE()<\/b><b><br \/>\n<\/b><b>NTH_VALUE()<\/b><b><br \/>\n<\/b><b>LEAD()<\/b><b><\/b><\/p>\n<p><b>\ucc38\uc870:<\/b><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\uc544\ub9c8\ub3c4 \uac00\uc7a5 \uba4b\uc9c4 SQL \uae30\ub2a5\uc77c \uac83\uc785\ub2c8\ub2e4: \ucc3d \ud568\uc218. <\/span><a href=\"https:\/\/blog.jooq.org\/2013\/11\/03\/probably-the-coolest-sql-feature-window-functions\/\"><span style=\"font-weight: 400\">https:\/\/blog.jooq.org\/2013\/11\/03\/probably-the-coolest-sql-feature-window-functions\/<\/span><\/a><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\ubd84\uc11d \ud568\uc218\uc758 \uc138\uacc4\ub97c \ub4e4\uc5ec\ub2e4\ubcf4\ub294 \ucc3d\uc785\ub2c8\ub2e4. <\/span><a href=\"https:\/\/blogs.oracle.com\/oraclemagazine\/a-window-into-the-world-of-analytic-functions\"><span style=\"font-weight: 400\">https:\/\/blogs.oracle.com\/oraclemagazine\/a-window-into-the-world-of-analytic-functions<\/span><\/a><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\uc624\ub77c\ud074 \ucc38\uc870: <\/span><a href=\"https:\/\/docs.oracle.com\/cd\/E11882_01\/server.112\/e41084\/functions004.htm#SQLRF06174\"><span style=\"font-weight: 400\">https:\/\/docs.oracle.com\/cd\/E11882_01\/server.112\/e41084\/functions004.htm#SQLRF06174<\/span><\/a><\/li>\n<\/ol>","protected":false},"excerpt":{"rendered":"<p>Use golf analogy when explaining to executives. Use a car analogy for all others. \u00a0&#8212; Confucius. The purpose of window functions is to translate the business reporting requirements declaratively and effectively to SQL so query performance and developer\/business-analyst efficiency improve [&hellip;]<\/p>","protected":false},"author":55,"featured_media":7450,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1814,1816,9417,1812],"tags":[2378,2306,1261,1725,2304],"ppma_author":[8929],"class_list":["post-6029","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-application-design","category-couchbase-server","category-performance","category-n1ql-query","tag-6-5","tag-analytical-functions","tag-json","tag-nosql-database","tag-reporting"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.4 (Yoast SEO v26.4) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>On Par with Window Functions. - The Couchbase Blog<\/title>\n<meta name=\"description\" content=\"This post focuses on Window Functions and it&#039;s purpose. How to write a query without using windows functions and with Window functions in Mad-Hatter.\" \/>\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.couchbase.com\/blog\/ko\/on-par-with-window-functions-in-n1ql\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"On Par with Window Functions.\" \/>\n<meta property=\"og:description\" content=\"This post focuses on Window Functions and it&#039;s purpose. How to write a query without using windows functions and with Window functions in Mad-Hatter.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/ko\/on-par-with-window-functions-in-n1ql\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2018-11-23T05:12:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T03:19:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/Transactions-alternative-2.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1400\" \/>\n\t<meta property=\"og:image:height\" content=\"553\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Keshav Murthy\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@rkeshavmurthy\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Keshav Murthy\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/\"},\"author\":{\"name\":\"Keshav Murthy\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c261644262bf98e146372fe647682636\"},\"headline\":\"On Par with Window Functions.\",\"datePublished\":\"2018-11-23T05:12:20+00:00\",\"dateModified\":\"2025-06-14T03:19:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/\"},\"wordCount\":515,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/Transactions-alternative-2.jpg\",\"keywords\":[\"6.5\",\"analytical functions\",\"JSON\",\"NoSQL Database\",\"reporting\"],\"articleSection\":[\"Application Design\",\"Couchbase Server\",\"High Performance\",\"SQL++ \/ N1QL Query\"],\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/\",\"name\":\"On Par with Window Functions. - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/Transactions-alternative-2.jpg\",\"datePublished\":\"2018-11-23T05:12:20+00:00\",\"dateModified\":\"2025-06-14T03:19:54+00:00\",\"description\":\"This post focuses on Window Functions and it's purpose. How to write a query without using windows functions and with Window functions in Mad-Hatter.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/Transactions-alternative-2.jpg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/Transactions-alternative-2.jpg\",\"width\":1400,\"height\":553,\"caption\":\"Jespsen Code Image\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"On Par with Window Functions.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c261644262bf98e146372fe647682636\",\"name\":\"Keshav Murthy\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/4e51d72fc07c662aa791316deafffac4\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/af74df754db27152971d0aed2f323ead5a1f9fe5afd0209af91e12e784451224?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/af74df754db27152971d0aed2f323ead5a1f9fe5afd0209af91e12e784451224?s=96&d=mm&r=g\",\"caption\":\"Keshav Murthy\"},\"description\":\"Keshav Murthy is a Vice President at Couchbase R&amp;D. Previously, he was at MapR, IBM, Informix, Sybase, with more than 20 years of experience in database design &amp; development. He lead the SQL and NoSQL R&amp;D team at IBM Informix. He has received two President's Club awards at Couchbase, two Outstanding Technical Achievement Awards at IBM. Keshav has a bachelor's degree in Computer Science and Engineering from the University of Mysore, India, and has received twenty four US patents.\",\"sameAs\":[\"https:\/\/blog.planetnosql.com\/\",\"https:\/\/x.com\/rkeshavmurthy\"],\"url\":\"https:\/\/www.couchbase.com\/blog\/ko\/author\/keshav-murthy\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"On Par with Window Functions. - The Couchbase Blog","description":"This post focuses on Window Functions and it's purpose. How to write a query without using windows functions and with Window functions in Mad-Hatter.","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.couchbase.com\/blog\/ko\/on-par-with-window-functions-in-n1ql\/","og_locale":"ko_KR","og_type":"article","og_title":"On Par with Window Functions.","og_description":"This post focuses on Window Functions and it's purpose. How to write a query without using windows functions and with Window functions in Mad-Hatter.","og_url":"https:\/\/www.couchbase.com\/blog\/ko\/on-par-with-window-functions-in-n1ql\/","og_site_name":"The Couchbase Blog","article_published_time":"2018-11-23T05:12:20+00:00","article_modified_time":"2025-06-14T03:19:54+00:00","og_image":[{"width":1400,"height":553,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/Transactions-alternative-2.jpg","type":"image\/jpeg"}],"author":"Keshav Murthy","twitter_card":"summary_large_image","twitter_creator":"@rkeshavmurthy","twitter_misc":{"Written by":"Keshav Murthy","Est. reading time":"4\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/"},"author":{"name":"Keshav Murthy","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c261644262bf98e146372fe647682636"},"headline":"On Par with Window Functions.","datePublished":"2018-11-23T05:12:20+00:00","dateModified":"2025-06-14T03:19:54+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/"},"wordCount":515,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/Transactions-alternative-2.jpg","keywords":["6.5","analytical functions","JSON","NoSQL Database","reporting"],"articleSection":["Application Design","Couchbase Server","High Performance","SQL++ \/ N1QL Query"],"inLanguage":"ko-KR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/","url":"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/","name":"On Par with Window Functions. - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/Transactions-alternative-2.jpg","datePublished":"2018-11-23T05:12:20+00:00","dateModified":"2025-06-14T03:19:54+00:00","description":"This post focuses on Window Functions and it's purpose. How to write a query without using windows functions and with Window functions in Mad-Hatter.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/"]}]},{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/Transactions-alternative-2.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/Transactions-alternative-2.jpg","width":1400,"height":553,"caption":"Jespsen Code Image"},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/on-par-with-window-functions-in-n1ql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"On Par with Window Functions."}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"\uce74\uc6b0\uce58\ubca0\uc774\uc2a4 \ube14\ub85c\uadf8","description":"NoSQL \ub370\uc774\ud130\ubca0\uc774\uc2a4, Couchbase","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"\uce74\uc6b0\uce58\ubca0\uc774\uc2a4 \ube14\ub85c\uadf8","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c261644262bf98e146372fe647682636","name":"\ucf00\uc0e4\ube0c \uba38\uc2dc","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/4e51d72fc07c662aa791316deafffac4","url":"https:\/\/secure.gravatar.com\/avatar\/af74df754db27152971d0aed2f323ead5a1f9fe5afd0209af91e12e784451224?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/af74df754db27152971d0aed2f323ead5a1f9fe5afd0209af91e12e784451224?s=96&d=mm&r=g","caption":"Keshav Murthy"},"description":"\ucf00\uc0e4\ube0c \uba38\uc2dc\ub294 Couchbase R&amp;D\uc758 \ubd80\uc0ac\uc7a5\uc785\ub2c8\ub2e4. \uc774\uc804\uc5d0\ub294 MapR, IBM, Informix, Sybase\uc5d0\uc11c \uadfc\ubb34\ud588\uc73c\uba70 \ub370\uc774\ud130\ubca0\uc774\uc2a4 \uc124\uacc4 \ubc0f \uac1c\ubc1c \ubd84\uc57c\uc5d0\uc11c 20\ub144 \uc774\uc0c1\uc758 \uacbd\ub825\uc744 \uc313\uc558\uc2b5\ub2c8\ub2e4. IBM Informix\uc5d0\uc11c SQL \ubc0f NoSQL R&amp;D \ud300\uc744 \uc774\ub04c\uc5c8\uc2b5\ub2c8\ub2e4. Couchbase\uc5d0\uc11c \ub450 \ubc88\uc758 President's Club \uc0c1\uc744, IBM\uc5d0\uc11c \ub450 \ubc88\uc758 \ub6f0\uc5b4\ub09c \uae30\uc220 \uc5c5\uc801\uc0c1\uc744 \uc218\uc0c1\ud588\uc2b5\ub2c8\ub2e4. \uc778\ub3c4 \ub9c8\uc774\uc18c\ub974 \ub300\ud559\uad50\uc5d0\uc11c \ucef4\ud4e8\ud130 \uacfc\ud559 \ubc0f \uacf5\ud559 \ud559\uc0ac \ud559\uc704\ub97c \ubc1b\uc558\uc73c\uba70, 24\uac1c\uc758 \ubbf8\uad6d \ud2b9\ud5c8\ub97c \ubcf4\uc720\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4.","sameAs":["https:\/\/blog.planetnosql.com\/","https:\/\/x.com\/rkeshavmurthy"],"url":"https:\/\/www.couchbase.com\/blog\/ko\/author\/keshav-murthy\/"}]}},"authors":[{"term_id":8929,"user_id":55,"is_guest":0,"slug":"keshav-murthy","display_name":"Keshav Murthy","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/af74df754db27152971d0aed2f323ead5a1f9fe5afd0209af91e12e784451224?s=96&d=mm&r=g","author_category":"","last_name":"Murthy","first_name":"Keshav","job_title":"","user_url":"https:\/\/blog.planetnosql.com\/","description":"\ucf00\uc0e4\ube0c \uba38\uc2dc\ub294 Couchbase R&amp;D\uc758 \ubd80\uc0ac\uc7a5\uc785\ub2c8\ub2e4. \uc774\uc804\uc5d0\ub294 MapR, IBM, Informix, Sybase\uc5d0\uc11c \uadfc\ubb34\ud588\uc73c\uba70 \ub370\uc774\ud130\ubca0\uc774\uc2a4 \uc124\uacc4 \ubc0f \uac1c\ubc1c \ubd84\uc57c\uc5d0\uc11c 20\ub144 \uc774\uc0c1\uc758 \uacbd\ub825\uc744 \uc313\uc558\uc2b5\ub2c8\ub2e4. IBM Informix\uc5d0\uc11c SQL \ubc0f NoSQL R&amp;D \ud300\uc744 \uc774\ub04c\uc5c8\uc2b5\ub2c8\ub2e4. Couchbase\uc5d0\uc11c \ub450 \ubc88\uc758 President's Club \uc0c1\uc744, IBM\uc5d0\uc11c \ub450 \ubc88\uc758 \uc6b0\uc218 \uae30\uc220 \uc5c5\uc801\uc0c1\uc744 \uc218\uc0c1\ud588\uc2b5\ub2c8\ub2e4. \uc778\ub3c4 \ub9c8\uc774\uc18c\ub974 \ub300\ud559\uad50\uc5d0\uc11c \ucef4\ud4e8\ud130 \uacfc\ud559 \ubc0f \uacf5\ud559 \ud559\uc0ac \ud559\uc704\ub97c \ubc1b\uc558\uc73c\uba70, 10\uac1c\uc758 \ubbf8\uad6d \ud2b9\ud5c8\ub97c \ubcf4\uc720\ud558\uace0 \uc788\uace0 3\uac1c\uc758 \ubbf8\uad6d \ud2b9\ud5c8\ub97c \ucd9c\uc6d0 \uc911\uc785\ub2c8\ub2e4."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/posts\/6029","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/users\/55"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/comments?post=6029"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/posts\/6029\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/media\/7450"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/media?parent=6029"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/categories?post=6029"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/tags?post=6029"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/ppma_author?post=6029"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}