{"id":7046,"date":"2018-08-28T07:56:20","date_gmt":"2018-08-28T14:56:20","guid":{"rendered":"http:\/\/www.mysqltutorial.org\/?page_id=7046"},"modified":"2024-01-04T06:43:43","modified_gmt":"2024-01-04T13:43:43","slug":"mysql-first_value-function","status":"publish","type":"page","link":"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-first_value-function\/","title":{"rendered":"MySQL FIRST_VALUE Function"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to use the MySQL <code>FIRST_VALUE()<\/code> function to get the first row of a frame, partition, or result set.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to MySQL FIRST_VALUE() function<\/h2>\n\n\n\n<p>The <code>FIRST_VALUE()<\/code> is a <a href=\"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/\">window function<\/a> that allows you to select the first row of a window frame, partition, or result set.<\/p>\n\n\n\n<p>The following illustrates the syntax of the <code>FIRST_VALUE()<\/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\">FIRST_VALUE (expression) OVER (\n   &#91;partition_clause]\n   &#91;order_clause]\n   &#91;frame_clause]\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<h3 class=\"wp-block-heading\">expression<\/h3>\n\n\n\n<p>The <code>FIRST_VALUE()<\/code> function returns the value of the <code>expression<\/code> from the first row of the window frame.<\/p>\n\n\n\n<p>The <code>OVER<\/code> clause consists of three clauses: <code>partition_clause<\/code>, <code>order_clause<\/code>, and <code>frame_clause<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">partition_clause<\/h3>\n\n\n\n<p>The <code>partition_clause<\/code> clause divides the rows of the result sets into partitions to which the function applies independently. The <code>partition_clause<\/code> has the following syntax:<\/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\">PARTITION BY expr1, expr2, ...<\/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<h3 class=\"wp-block-heading\">order_clause<\/h3>\n\n\n\n<p>The <code>order_clause<\/code> clause specifies the logical order of rows in each partition on which the <code>FIRST_VALUE()<\/code> function operates. The following shows the syntax of the <code>order_clause<\/code>:<\/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\">ORDER BY expr1 &#91;ASC|DESC], expr2 &#91;ASC|DESC], ...<\/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<h3 class=\"wp-block-heading\">frame_clause<\/h3>\n\n\n\n<p>The <code>frame_clause<\/code> defines the subset (or frame) of the current partition. For detailed information on the frame clause syntax, check out the <a href=\"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/\">window functions tutorial<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">MySQL FIRST_VALUE() function examples<\/h2>\n\n\n\n<p>The following statements <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-create-table\/\">create a new table<\/a> named <code>overtime<\/code> and <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-insert\/\">insert<\/a> sample data for the demonstration:<\/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\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> overtime (\n    employee_name <span class=\"hljs-built_in\">VARCHAR<\/span>(<span class=\"hljs-number\">50<\/span>) <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-literal\">NULL<\/span>,\n    department <span class=\"hljs-built_in\">VARCHAR<\/span>(<span class=\"hljs-number\">50<\/span>) <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-literal\">NULL<\/span>,\n    <span class=\"hljs-keyword\">hours<\/span> <span class=\"hljs-built_in\">INT<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-literal\">NULL<\/span>,\n    PRIMARY <span class=\"hljs-keyword\">KEY<\/span> (employee_name , department)\n);\n<span class=\"hljs-keyword\">INSERT<\/span> <span class=\"hljs-keyword\">INTO<\/span> overtime(employee_name, department, <span class=\"hljs-keyword\">hours<\/span>)\n<span class=\"hljs-keyword\">VALUES<\/span>(<span class=\"hljs-string\">'Diane Murphy'<\/span>,<span class=\"hljs-string\">'Accounting'<\/span>,<span class=\"hljs-number\">37<\/span>),\n(<span class=\"hljs-string\">'Mary Patterson'<\/span>,<span class=\"hljs-string\">'Accounting'<\/span>,<span class=\"hljs-number\">74<\/span>),\n(<span class=\"hljs-string\">'Jeff Firrelli'<\/span>,<span class=\"hljs-string\">'Accounting'<\/span>,<span class=\"hljs-number\">40<\/span>),\n(<span class=\"hljs-string\">'William Patterson'<\/span>,<span class=\"hljs-string\">'Finance'<\/span>,<span class=\"hljs-number\">58<\/span>),\n(<span class=\"hljs-string\">'Gerard Bondur'<\/span>,<span class=\"hljs-string\">'Finance'<\/span>,<span class=\"hljs-number\">47<\/span>),\n(<span class=\"hljs-string\">'Anthony Bow'<\/span>,<span class=\"hljs-string\">'Finance'<\/span>,<span class=\"hljs-number\">66<\/span>),\n(<span class=\"hljs-string\">'Leslie Jennings'<\/span>,<span class=\"hljs-string\">'IT'<\/span>,<span class=\"hljs-number\">90<\/span>),\n(<span class=\"hljs-string\">'Leslie Thompson'<\/span>,<span class=\"hljs-string\">'IT'<\/span>,<span class=\"hljs-number\">88<\/span>),\n(<span class=\"hljs-string\">'Julie Firrelli'<\/span>,<span class=\"hljs-string\">'Sales'<\/span>,<span class=\"hljs-number\">81<\/span>),\n(<span class=\"hljs-string\">'Steve Patterson'<\/span>,<span class=\"hljs-string\">'Sales'<\/span>,<span class=\"hljs-number\">29<\/span>),\n(<span class=\"hljs-string\">'Foon Yue Tseng'<\/span>,<span class=\"hljs-string\">'Sales'<\/span>,<span class=\"hljs-number\">65<\/span>),\n(<span class=\"hljs-string\">'George Vanauf'<\/span>,<span class=\"hljs-string\">'Marketing'<\/span>,<span class=\"hljs-number\">89<\/span>),\n(<span class=\"hljs-string\">'Loui Bondur'<\/span>,<span class=\"hljs-string\">'Marketing'<\/span>,<span class=\"hljs-number\">49<\/span>),\n(<span class=\"hljs-string\">'Gerard Hernandez'<\/span>,<span class=\"hljs-string\">'Marketing'<\/span>,<span class=\"hljs-number\">66<\/span>),\n(<span class=\"hljs-string\">'Pamela Castillo'<\/span>,<span class=\"hljs-string\">'SCM'<\/span>,<span class=\"hljs-number\">96<\/span>),\n(<span class=\"hljs-string\">'Larry Bott'<\/span>,<span class=\"hljs-string\">'SCM'<\/span>,<span class=\"hljs-number\">100<\/span>),\n(<span class=\"hljs-string\">'Barry Jones'<\/span>,<span class=\"hljs-string\">'SCM'<\/span>,<span class=\"hljs-number\">65<\/span>);\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<h3 class=\"wp-block-heading\">1) Using MySQL FIRST_VALUE() function over the whole query result set example<\/h3>\n\n\n\n<p>The following statement gets the employee&#8217;s name, overtime, and the employee who has the least overtime:<\/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\">SELECT<\/span>\n    employee_name,\n    <span class=\"hljs-keyword\">hours<\/span>,\n    <span class=\"hljs-keyword\">FIRST_VALUE<\/span>(employee_name) <span class=\"hljs-keyword\">OVER<\/span> (\n        <span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> <span class=\"hljs-keyword\">hours<\/span>\n    ) least_over_time\n<span class=\"hljs-keyword\">FROM<\/span>\n    overtime;<\/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>Here is the output:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"261\" height=\"239\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-FIRST_VALUE-Function-Example.png\" alt=\"MySQL FIRST_VALUE Function Example\" class=\"wp-image-7049\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-FIRST_VALUE-Function-Example.png 261w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-FIRST_VALUE-Function-Example-200x183.png 200w\" sizes=\"auto, (max-width: 261px) 100vw, 261px\" \/><\/figure>\n\n\n\n<p>In this example, the <code>ORDER BY<\/code> clause ordered the rows in the result set by hours and the <code>FIRST_VALUE()<\/code> picked the first row indicating the employee who had the least overtime.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2) Using MySQL FIRST_VALUE() function with partitions example<\/h3>\n\n\n\n<p>The following statement finds the employee who has the least overtime&nbsp;in every department:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" 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    employee_name,\n    department,\n    <span class=\"hljs-keyword\">hours<\/span>,\n    <span class=\"hljs-keyword\">FIRST_VALUE<\/span>(employee_name) <span class=\"hljs-keyword\">OVER<\/span> (\n        <span class=\"hljs-keyword\">PARTITION<\/span> <span class=\"hljs-keyword\">BY<\/span> department\n        <span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> <span class=\"hljs-keyword\">hours<\/span>\n    ) least_over_time\n<span class=\"hljs-keyword\">FROM<\/span>\n    overtime;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><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 output is:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"336\" height=\"357\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-FIRST_VALUE-Function-Over-Partition-Example.png\" alt=\"\" class=\"wp-image-7050\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-FIRST_VALUE-Function-Over-Partition-Example.png 336w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-FIRST_VALUE-Function-Over-Partition-Example-188x200.png 188w\" sizes=\"auto, (max-width: 336px) 100vw, 336px\" \/><\/figure>\n\n\n\n<p>In this example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, the <code>PARTITION BY<\/code> clause divides the employees into partitions by departments. In other words, each partition consists of employees who belong to the same department.<\/li>\n\n\n\n<li>Second, the <code>ORDER BY<\/code> clause specifies the order of rows in each partition.<\/li>\n\n\n\n<li>Third, the <code>FIRST_VALUE()<\/code> operates on each partition sorted by the hours. It returns the first row in each partition which is the employee who has the least overtime within the department.<\/li>\n<\/ul>\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>FIRST_VALUE()<\/code> function to get the first row of a window frame.<\/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=\"7046\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-first_value-function\/\"\n\t\t\t\tdata-post-title=\"MySQL FIRST_VALUE 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=\"7046\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-first_value-function\/\"\n\t\t\t\tdata-post-title=\"MySQL FIRST_VALUE 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 FIRST_VALUE() function to get the first row of a window frame.<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":6941,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-7046","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 FIRST_VALUE Window Function By Practical Examples<\/title>\n<meta name=\"description\" content=\"This tutorial shows you how to use the MySQL FIRST_VALUE() function to get the first row of a window frame.\" \/>\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-first_value-function\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL FIRST_VALUE Window Function By Practical Examples\" \/>\n<meta property=\"og:description\" content=\"This tutorial shows you how to use the MySQL FIRST_VALUE() function to get the first row of a window frame.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-first_value-function\/\" \/>\n<meta property=\"og:site_name\" content=\"MySQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-04T13:43:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-FIRST_VALUE-Function-Example.png\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 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-first_value-function\\\/\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-window-functions\\\/mysql-first_value-function\\\/\",\"name\":\"MySQL FIRST_VALUE Window Function By Practical Examples\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-window-functions\\\/mysql-first_value-function\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-window-functions\\\/mysql-first_value-function\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/MySQL-FIRST_VALUE-Function-Example.png\",\"datePublished\":\"2018-08-28T14:56:20+00:00\",\"dateModified\":\"2024-01-04T13:43:43+00:00\",\"description\":\"This tutorial shows you how to use the MySQL FIRST_VALUE() function to get the first row of a window frame.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-window-functions\\\/mysql-first_value-function\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-window-functions\\\/mysql-first_value-function\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-window-functions\\\/mysql-first_value-function\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/MySQL-FIRST_VALUE-Function-Example.png\",\"contentUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/MySQL-FIRST_VALUE-Function-Example.png\",\"width\":261,\"height\":239,\"caption\":\"MySQL FIRST_VALUE Function Example\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-window-functions\\\/mysql-first_value-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 FIRST_VALUE 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 FIRST_VALUE Window Function By Practical Examples","description":"This tutorial shows you how to use the MySQL FIRST_VALUE() function to get the first row of a window frame.","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-first_value-function\/","og_locale":"en_US","og_type":"article","og_title":"MySQL FIRST_VALUE Window Function By Practical Examples","og_description":"This tutorial shows you how to use the MySQL FIRST_VALUE() function to get the first row of a window frame.","og_url":"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-first_value-function\/","og_site_name":"MySQL Tutorial","article_modified_time":"2024-01-04T13:43:43+00:00","og_image":[{"url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-FIRST_VALUE-Function-Example.png","type":"","width":"","height":""}],"twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-first_value-function\/","url":"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-first_value-function\/","name":"MySQL FIRST_VALUE Window Function By Practical Examples","isPartOf":{"@id":"https:\/\/www.mysqltutorial.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-first_value-function\/#primaryimage"},"image":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-first_value-function\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-FIRST_VALUE-Function-Example.png","datePublished":"2018-08-28T14:56:20+00:00","dateModified":"2024-01-04T13:43:43+00:00","description":"This tutorial shows you how to use the MySQL FIRST_VALUE() function to get the first row of a window frame.","breadcrumb":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-first_value-function\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-first_value-function\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-first_value-function\/#primaryimage","url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-FIRST_VALUE-Function-Example.png","contentUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-FIRST_VALUE-Function-Example.png","width":261,"height":239,"caption":"MySQL FIRST_VALUE Function Example"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-first_value-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 FIRST_VALUE 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\/7046","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=7046"}],"version-history":[{"count":2,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/7046\/revisions"}],"predecessor-version":[{"id":14188,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/7046\/revisions\/14188"}],"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=7046"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}