{"id":1249,"date":"2019-02-21T08:57:18","date_gmt":"2019-02-21T01:57:18","guid":{"rendered":"http:\/\/www.sqlservertutorial.net\/?page_id=1249"},"modified":"2021-04-28T14:47:09","modified_gmt":"2021-04-28T07:47:09","slug":"sql-server-window-functions","status":"publish","type":"page","link":"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/","title":{"rendered":"SQL Server Window Functions"},"content":{"rendered":"\n<p>SQL Server Window Functions calculate an aggregate value based on a group of rows and return multiple rows for each group.<br>\n<input id=\"search\" class=\"light-table-filter\" type=\"text\" placeholder=\"Type a function name to search...\" data-table=\"functions\"><\/p>\n\n\n\n<figure class=\"wp-block-table responsive functions\"><table><thead><tr><th>Name<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/sql-server-cume_dist-function\/\">CUME_DIST<\/a><\/td><td>Calculate the cumulative distribution of a value in a set of values<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/sql-server-dense_rank-function\/\">DENSE_RANK<\/a><\/td><td>Assign a rank value to each row within a partition of a result, with no gaps in rank values.<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/sql-server-first_value-function\/\">FIRST_VALUE<\/a><\/td><td>Get the value of the first row in an ordered partition of a result set.<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/sql-server-lag-function\/\">LAG<\/a><\/td><td>Provide access to a row at a given physical offset that comes before the current row.<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/sql-server-last_value-function\/\">LAST_VALUE<\/a><\/td><td>Get the value of the last row in an ordered partition of a result set.<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/sql-server-lead-function\/\">LEAD<\/a><\/td><td>Provide access to a row at a given physical offset that follows the current row.<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/sql-server-ntile-function\/\">NTILE<\/a><\/td><td>Distribute rows of an ordered partition into a number of groups or buckets<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/sql-server-percent_rank-function\/\">PERCENT_RANK<\/a><\/td><td>Calculate the percent rank of a value in a set of values.<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/sql-server-rank-function\/\">RANK<\/a><\/td><td>Assign a rank value to each row within a partition of a result set<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/sql-server-row_number-function\/\">ROW_NUMBER<\/a><\/td><td>Assign a unique sequential integer to rows within a partition of a result set, the first row starts from 1.<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>SQL Server Window Functions calculate an aggregate value based on a group of rows and return multiple rows for each group.<\/p>\n","protected":false},"author":1,"featured_media":2742,"parent":0,"menu_order":15,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1249","page","type-page","status-publish","has-post-thumbnail","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SQL Server Window Functions<\/title>\n<meta name=\"description\" content=\"SQL Server Window Functions calculate an aggregate value based on a group of rows and return multiple rows for each group.\" \/>\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.sqlservertutorial.net\/sql-server-window-functions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Server Window Functions\" \/>\n<meta property=\"og:description\" content=\"SQL Server Window Functions calculate an aggregate value based on a group of rows and return multiple rows for each group.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Server Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-28T07:47:09+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-window-functions\\\/\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-window-functions\\\/\",\"name\":\"SQL Server Window Functions\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-window-functions\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-window-functions\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/sql-server-window-functions.svg\",\"datePublished\":\"2019-02-21T01:57:18+00:00\",\"dateModified\":\"2021-04-28T07:47:09+00:00\",\"description\":\"SQL Server Window Functions calculate an aggregate value based on a group of rows and return multiple rows for each group.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-window-functions\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-window-functions\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-window-functions\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/sql-server-window-functions.svg\",\"contentUrl\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/sql-server-window-functions.svg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-window-functions\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Server Window Functions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\",\"name\":\"SQL Server Tutorial\",\"description\":\"The Practical SQL Server Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQL Server Window Functions","description":"SQL Server Window Functions calculate an aggregate value based on a group of rows and return multiple rows for each group.","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.sqlservertutorial.net\/sql-server-window-functions\/","og_locale":"en_US","og_type":"article","og_title":"SQL Server Window Functions","og_description":"SQL Server Window Functions calculate an aggregate value based on a group of rows and return multiple rows for each group.","og_url":"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/","og_site_name":"SQL Server Tutorial","article_modified_time":"2021-04-28T07:47:09+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/","url":"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/","name":"SQL Server Window Functions","isPartOf":{"@id":"https:\/\/www.sqlservertutorial.net\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/#primaryimage"},"image":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/sql-server-window-functions.svg","datePublished":"2019-02-21T01:57:18+00:00","dateModified":"2021-04-28T07:47:09+00:00","description":"SQL Server Window Functions calculate an aggregate value based on a group of rows and return multiple rows for each group.","breadcrumb":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/#primaryimage","url":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/sql-server-window-functions.svg","contentUrl":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/sql-server-window-functions.svg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlservertutorial.net\/"},{"@type":"ListItem","position":2,"name":"SQL Server Window Functions"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlservertutorial.net\/#website","url":"https:\/\/www.sqlservertutorial.net\/","name":"SQL Server Tutorial","description":"The Practical SQL Server Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlservertutorial.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/1249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/comments?post=1249"}],"version-history":[{"count":1,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/1249\/revisions"}],"predecessor-version":[{"id":2761,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/1249\/revisions\/2761"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/media\/2742"}],"wp:attachment":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/media?parent=1249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}