{"id":6979,"date":"2018-08-25T17:49:41","date_gmt":"2018-08-26T00:49:41","guid":{"rendered":"http:\/\/www.mysqltutorial.org\/?page_id=6979"},"modified":"2024-01-04T06:48:51","modified_gmt":"2024-01-04T13:48:51","slug":"mysql-ntile-function","status":"publish","type":"page","link":"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-ntile-function\/","title":{"rendered":"MySQL NTILE Function"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to use the MySQL <code>NTILE()<\/code> function to divide rows into a specified number of groups.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to MySQL NTILE() function<\/h2>\n\n\n\n<p>The MySQL <code>NTILE()<\/code> function divides rows in a sorted partition into a specific number of groups. Each group is assigned a bucket number starting at one. For each row, the <code>NTILE()<\/code> function returns a bucket number representing the group to which the row belongs.<\/p>\n\n\n\n<p>The following shows the syntax of the <code>NTILE()<\/code> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">NTILE(n) OVER (\n    PARTITION BY &lt;expression&gt;&#91;{,&lt;expression&gt;...}]\n    ORDER BY &lt;expression&gt; &#91;ASC|DESC], &#91;{,&lt;expression&gt;...}]\n)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this syntax:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u00a0<code>n<\/code> is a literal positive integer. The bucket number is in the range of 1 to <code>n<\/code>.<\/li>\n\n\n\n<li>The <code>PARTITION BY<\/code> divides the result set returned from the <code>FROM<\/code> clause into partitions to which the <code>NTILE()<\/code> function is applied.<\/li>\n\n\n\n<li>The <code>ORDER BY<\/code> clause specifies the order in which the <code>NTILE()<\/code> values are assigned to the rows in a partition.<\/li>\n<\/ul>\n\n\n\n<p>Note that if the number of partition rows is not divisible by <code>n<\/code>, the <code>NTILE()<\/code> function will result in groups of two sizes with a difference of one. The larger groups always come before the smaller group in the order specified by the <code>ORDER BY<\/code> clause.<\/p>\n\n\n\n<p>On the other hand, if the total of partition rows is divisible by <code>n<\/code>, the rows will be divided evenly among groups.<\/p>\n\n\n\n<p>See the following table that stores nine integers from one to nine:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> t (\n    val <span class=\"hljs-built_in\">INT<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-literal\">NULL<\/span>\n);\n\n<span class=\"hljs-keyword\">INSERT<\/span> <span class=\"hljs-keyword\">INTO<\/span> t(val) \n<span class=\"hljs-keyword\">VALUES<\/span>(<span class=\"hljs-number\">1<\/span>),(<span class=\"hljs-number\">2<\/span>),(<span class=\"hljs-number\">3<\/span>),(<span class=\"hljs-number\">4<\/span>),(<span class=\"hljs-number\">5<\/span>),(<span class=\"hljs-number\">6<\/span>),(<span class=\"hljs-number\">7<\/span>),(<span class=\"hljs-number\">8<\/span>),(<span class=\"hljs-number\">9<\/span>);\n\n\n<span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> t;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>If you use the <code>NTILE()<\/code> function to divide nine rows into four groups, you will end up at the first group with three rows and the other three groups with four rows.<\/p>\n\n\n\n<p>See the following demonstration:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    val, \n    NTILE (<span class=\"hljs-number\">4<\/span>) <span class=\"hljs-keyword\">OVER<\/span> (\n        <span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> val\n    ) bucket_no\n<span class=\"hljs-keyword\">FROM<\/span> \n    t;\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Here is the output:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"130\" height=\"200\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-NTILE-function-groups-with-the-different-number-of-rows.png\" alt=\"MySQL NTILE function - groups with the different number of rows\" class=\"wp-image-6982\" title=\"MySQL NTILE function - groups with the different number of rows\"\/><\/figure>\n\n\n\n<p>As you can see from the output, the first group has three rows while the other groups have two rows.<\/p>\n\n\n\n<p>Let&#8217;s change the number of groups from four to three as shown in the following query:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    val, \n    NTILE (<span class=\"hljs-number\">3<\/span>) <span class=\"hljs-keyword\">OVER<\/span> (\n        <span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> val\n    ) bucket_no\n<span class=\"hljs-keyword\">FROM<\/span> \n    t;\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The result set now has three groups with the same number of rows.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"136\" height=\"178\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-NTILE-function-groups-with-difference-in-rows.png\" alt=\"MySQL NTILE function - groups with difference in rows\" class=\"wp-image-6981\" title=\"MySQL NTILE function - groups with difference in rows\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">MySQL NTILE() function example<\/h2>\n\n\n\n<p>We will use the <code>orders<\/code>, <code>orderDetails<\/code>&nbsp;, and <code>products<\/code> tables from the <a href=\"https:\/\/www.mysqltutorial.org\/getting-started-with-mysql\/mysql-sample-database\/\">sample database<\/a> for the demonstration.<\/p>\n\n\n\n<p>See the following query:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">WITH<\/span> productline_sales <span class=\"hljs-keyword\">AS<\/span> (\n    <span class=\"hljs-keyword\">SELECT<\/span> productline,\n           <span class=\"hljs-keyword\">year<\/span>(orderDate) order_year,\n           <span class=\"hljs-keyword\">ROUND<\/span>(<span class=\"hljs-keyword\">SUM<\/span>(quantityOrdered * priceEach),<span class=\"hljs-number\">0<\/span>) order_value\n    <span class=\"hljs-keyword\">FROM<\/span> orders\n    <span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span> orderdetails <span class=\"hljs-keyword\">USING<\/span> (orderNumber)\n    <span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span> products <span class=\"hljs-keyword\">USING<\/span> (productCode)\n    <span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span> productline, order_year\n)\n<span class=\"hljs-keyword\">SELECT<\/span>\n    productline, \n    order_year, \n    order_value,\n    NTILE(<span class=\"hljs-number\">3<\/span>) <span class=\"hljs-keyword\">OVER<\/span> (\n        <span class=\"hljs-keyword\">PARTITION<\/span> <span class=\"hljs-keyword\">BY<\/span> order_year\n        <span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> order_value <span class=\"hljs-keyword\">DESC<\/span>\n    ) product_line_group\n<span class=\"hljs-keyword\">FROM<\/span> \n    productline_sales;\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, in the <code>productline_sales<\/code> common table expression, we get the total order value of every product line by year.<\/li>\n\n\n\n<li>Then, we use the <code>NTILE()<\/code> function to divide the sales by product line in each year into three groups.<\/li>\n<\/ul>\n\n\n\n<p>Here is the output:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"399\" height=\"440\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-NTILE-function-with-CTE-example.png\" alt=\"MySQL NTILE function with CTE example\" class=\"wp-image-6987\" title=\"MySQL NTILE function with CTE example\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-NTILE-function-with-CTE-example.png 399w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-NTILE-function-with-CTE-example-181x200.png 181w\" sizes=\"auto, (max-width: 399px) 100vw, 399px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the MySQL <code>NTILE()<\/code> function to distribute rows into a specified number of groups.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful? <\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"6979\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-ntile-function\/\"\n\t\t\t\tdata-post-title=\"MySQL NTILE Function\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"6979\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-ntile-function\/\"\n\t\t\t\tdata-post-title=\"MySQL NTILE Function\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows you how to use the MySQL NTILE() function to divide rows into a specified number of groups.<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":6941,"menu_order":7,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-6979","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MySQL NTILE Function By Practical Examples<\/title>\n<meta name=\"description\" content=\"This tutorial shows you how to use the MySQL NTILE() function to divide rows into a specified number of groups.\" \/>\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.mysqltutorial.org\/mysql-window-functions\/mysql-ntile-function\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL NTILE Function By Practical Examples\" \/>\n<meta property=\"og:description\" content=\"This tutorial shows you how to use the MySQL NTILE() function to divide rows into a specified number of groups.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-ntile-function\/\" \/>\n<meta property=\"og:site_name\" content=\"MySQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-04T13:48:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-NTILE-function-groups-with-the-different-number-of-rows.png\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-window-functions\\\/mysql-ntile-function\\\/\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-window-functions\\\/mysql-ntile-function\\\/\",\"name\":\"MySQL NTILE Function By Practical Examples\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-window-functions\\\/mysql-ntile-function\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-window-functions\\\/mysql-ntile-function\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/MySQL-NTILE-function-groups-with-the-different-number-of-rows.png\",\"datePublished\":\"2018-08-26T00:49:41+00:00\",\"dateModified\":\"2024-01-04T13:48:51+00:00\",\"description\":\"This tutorial shows you how to use the MySQL NTILE() function to divide rows into a specified number of groups.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-window-functions\\\/mysql-ntile-function\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-window-functions\\\/mysql-ntile-function\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-window-functions\\\/mysql-ntile-function\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/MySQL-NTILE-function-groups-with-the-different-number-of-rows.png\",\"contentUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/MySQL-NTILE-function-groups-with-the-different-number-of-rows.png\",\"width\":130,\"height\":200},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-window-functions\\\/mysql-ntile-function\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL Window Functions\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-window-functions\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"MySQL NTILE Function\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\",\"name\":\"MySQL Tutorial\",\"description\":\"A comprehensive MySQL Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mysqltutorial.org\\\/?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":"MySQL NTILE Function By Practical Examples","description":"This tutorial shows you how to use the MySQL NTILE() function to divide rows into a specified number of groups.","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.mysqltutorial.org\/mysql-window-functions\/mysql-ntile-function\/","og_locale":"en_US","og_type":"article","og_title":"MySQL NTILE Function By Practical Examples","og_description":"This tutorial shows you how to use the MySQL NTILE() function to divide rows into a specified number of groups.","og_url":"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-ntile-function\/","og_site_name":"MySQL Tutorial","article_modified_time":"2024-01-04T13:48:51+00:00","og_image":[{"url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-NTILE-function-groups-with-the-different-number-of-rows.png","type":"","width":"","height":""}],"twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-ntile-function\/","url":"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-ntile-function\/","name":"MySQL NTILE Function By Practical Examples","isPartOf":{"@id":"https:\/\/www.mysqltutorial.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-ntile-function\/#primaryimage"},"image":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-ntile-function\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-NTILE-function-groups-with-the-different-number-of-rows.png","datePublished":"2018-08-26T00:49:41+00:00","dateModified":"2024-01-04T13:48:51+00:00","description":"This tutorial shows you how to use the MySQL NTILE() function to divide rows into a specified number of groups.","breadcrumb":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-ntile-function\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-ntile-function\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-ntile-function\/#primaryimage","url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-NTILE-function-groups-with-the-different-number-of-rows.png","contentUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-NTILE-function-groups-with-the-different-number-of-rows.png","width":130,"height":200},{"@type":"BreadcrumbList","@id":"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-ntile-function\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.mysqltutorial.org\/"},{"@type":"ListItem","position":2,"name":"MySQL Window Functions","item":"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/"},{"@type":"ListItem","position":3,"name":"MySQL NTILE Function"}]},{"@type":"WebSite","@id":"https:\/\/www.mysqltutorial.org\/#website","url":"https:\/\/www.mysqltutorial.org\/","name":"MySQL Tutorial","description":"A comprehensive MySQL Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mysqltutorial.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/6979","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/comments?post=6979"}],"version-history":[{"count":1,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/6979\/revisions"}],"predecessor-version":[{"id":14191,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/6979\/revisions\/14191"}],"up":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/6941"}],"wp:attachment":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/media?parent=6979"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}