{"id":3121,"date":"2025-01-27T06:02:37","date_gmt":"2025-01-27T13:02:37","guid":{"rendered":"https:\/\/www.sqltutorial.org\/?page_id=3121"},"modified":"2025-02-04T06:55:41","modified_gmt":"2025-02-04T13:55:41","slug":"sql-right","status":"publish","type":"page","link":"https:\/\/www.sqltutorial.org\/sql-string-functions\/sql-right\/","title":{"rendered":"SQL RIGHT Function"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn how to use the SQL <code>RIGHT<\/code> function to return a specified number of characters from the end of a string.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='introduction-to-the-sql-right-function'>Introduction to the SQL RIGHT Function <a href=\"#introduction-to-the-sql-right-function\" class=\"anchor\" id=\"introduction-to-the-sql-right-function\" title=\"Anchor for Introduction to the SQL RIGHT Function\">#<\/a><\/h2>\n\n\n\n<p>In SQL, the <code>RIGHT<\/code> function takes a string and returns a specified number of characters from the end ( the right) of a string.<\/p>\n\n\n\n<p>Here&#8217;s the syntax of the <code>RIGHT<\/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\">RIGHT(string, number_of_characters)<\/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>The <code>RIGHT<\/code> function accepts two parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>string<\/code>: The input string from which you want to return the characters.<\/li>\n\n\n\n<li><code>number_of_characters<\/code>: The number of characters you want to return from the input string.<\/li>\n<\/ul>\n\n\n\n<p>The <code>RIGHT<\/code> function returns a string that contains a specified number of characters from the right of the input string.<\/p>\n\n\n\n<p>It returns <code>NULL<\/code> if the input <code>string<\/code> or the <code>number_of_characters<\/code> is <code>NULL<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='basic-sql-right-function-example'>Basic SQL RIGHT function example <a href=\"#basic-sql-right-function-example\" class=\"anchor\" id=\"basic-sql-right-function-example\" title=\"Anchor for Basic SQL RIGHT function example\">#<\/a><\/h2>\n\n\n\n<p>The following <a href=\"https:\/\/www.sqltutorial.org\/sql-select\/\">query<\/a> uses the <code>RIGHT<\/code> function to return the extension of a file name:<\/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\">SELECT<\/span>\n  <span class=\"hljs-keyword\">RIGHT<\/span>(<span class=\"hljs-string\">'resume.pdf'<\/span>, <span class=\"hljs-number\">3<\/span>) extension;<\/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><a href=\"https:\/\/www.sqltutorial.org\/playground\/?q=U0VMRUNUIFJJR0hUKCdyZXN1bWUucGRmJywgMykgZXh0ZW5zaW9uOw%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Output:<\/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\"> extension\n<span class=\"hljs-comment\">-----------<\/span>\n pdf<\/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<h2 class=\"wp-block-heading\" id='extracting-file-extensions'>Extracting file extensions <a href=\"#extracting-file-extensions\" class=\"anchor\" id=\"extracting-file-extensions\" title=\"Anchor for Extracting file extensions\">#<\/a><\/h2>\n\n\n\n<p>First, <a href=\"https:\/\/www.sqltutorial.org\/sql-create-table\/\">create a new table<\/a> called <code>performance_evaluations<\/code> to store the employees&#8217; performance evaluations:<\/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> performance_evaluations (\n  employee_id <span class=\"hljs-built_in\">INT<\/span> PRIMARY <span class=\"hljs-keyword\">KEY<\/span>,\n  rating <span class=\"hljs-built_in\">INT<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-literal\">NULL<\/span>,\n  evaluation_form <span class=\"hljs-built_in\">VARCHAR<\/span>(<span class=\"hljs-number\">255<\/span>) <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-literal\">NULL<\/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<p><a href=\"https:\/\/www.sqltutorial.org\/playground\/?q=Q1JFQVRFIFRBQkxFIHBlcmZvcm1hbmNlX2V2YWx1YXRpb25zICggZW1wbG95ZWVfaWQgSU5UIFBSSU1BUlkgS0VZLCByYXRpbmcgSU5UIE5PVCBOVUxMLCBldmFsdWF0aW9uX2Zvcm0gVkFSQ0hBUigyNTUpIE5PVCBOVUxMICk7\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Second, <a href=\"https:\/\/www.sqltutorial.org\/sql-insert\/\">insert rows<\/a> into the <code>performance_evaluations<\/code> table:<\/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\">INSERT<\/span> <span class=\"hljs-keyword\">INTO<\/span>\n  performance_evaluations (employee_id, rating, evaluation_form)\n<span class=\"hljs-keyword\">VALUES<\/span>\n  (<span class=\"hljs-number\">101<\/span>, <span class=\"hljs-number\">4<\/span>, <span class=\"hljs-string\">'neena.pdf'<\/span>),\n  (<span class=\"hljs-number\">102<\/span>, <span class=\"hljs-number\">3<\/span>, <span class=\"hljs-string\">'lex.pdf'<\/span>),\n  (<span class=\"hljs-number\">103<\/span>, <span class=\"hljs-number\">5<\/span>, <span class=\"hljs-string\">'alexander.doc'<\/span>),\n  (<span class=\"hljs-number\">104<\/span>, <span class=\"hljs-number\">3<\/span>, <span class=\"hljs-string\">'bruce.xls'<\/span>),\n  (<span class=\"hljs-number\">105<\/span>, <span class=\"hljs-number\">3<\/span>, <span class=\"hljs-string\">'david.xls'<\/span>);<\/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><a href=\"https:\/\/www.sqltutorial.org\/playground\/?q=SU5TRVJUIElOVE8gcGVyZm9ybWFuY2VfZXZhbHVhdGlvbnMgKGVtcGxveWVlX2lkLCByYXRpbmcsIGV2YWx1YXRpb25fZm9ybSkgVkFMVUVTICgxMDEsIDQsICduZWVuYS5wZGYnKSwgKDEwMiwgMywgJ2xleC5wZGYnKSwgKDEwMywgNSwgJ2FsZXhhbmRlci5kb2MnKSwgKDEwNCwgMywgJ2JydWNlLnhscycpLCAoMTA1LCAzLCAnZGF2aWQueGxzJyk7\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Third, <a href=\"https:\/\/www.sqltutorial.org\/sql-select\/\">retrieve data<\/a> from the <code>performance_evaluations<\/code> table:<\/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  *\n<span class=\"hljs-keyword\">FROM<\/span>\n  performance_evaluations;<\/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><a href=\"https:\/\/www.sqltutorial.org\/playground\/?q=U0VMRUNUICogRlJPTSBwZXJmb3JtYW5jZV9ldmFsdWF0aW9uczs%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"> employee_id | rating | evaluation_form\n<span class=\"hljs-comment\">-------------+--------+-----------------<\/span>\n         101 |      4 | neena.pdf\n         102 |      3 | lex.pdf\n         103 |      5 | alexander.doc\n         104 |      3 | bruce.xls\n         105 |      3 | david.xls<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><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<h2 class=\"wp-block-heading\" id='using-the-right-function-with-table-data'>Using the RIGHT function with table data <a href=\"#using-the-right-function-with-table-data\" class=\"anchor\" id=\"using-the-right-function-with-table-data\" title=\"Anchor for Using the RIGHT function with table data\">#<\/a><\/h2>\n\n\n\n<p>The following query uses the <code>RIGHT<\/code> function to retrieve the employee name, ranting, evaluation forms, and the form&#8217;s extensions:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" 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  first_name,\n  rating,\n  evaluation_form,\n  <span class=\"hljs-keyword\">RIGHT<\/span>(evaluation_form, <span class=\"hljs-number\">3<\/span>) form_extension\n<span class=\"hljs-keyword\">FROM<\/span>\n  performance_evaluations p\n  <span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span> employees e <span class=\"hljs-keyword\">ON<\/span> e.employee_id = p.employee_id\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span>\n  first_name;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><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><a href=\"https:\/\/www.sqltutorial.org\/playground\/?q=U0VMRUNUIGZpcnN0X25hbWUsIHJhdGluZywgZXZhbHVhdGlvbl9mb3JtLCBSSUdIVChldmFsdWF0aW9uX2Zvcm0sIDMpIGZvcm1fZXh0ZW5zaW9uIEZST00gcGVyZm9ybWFuY2VfZXZhbHVhdGlvbnMgcCBJTk5FUiBKT0lOIGVtcGxveWVlcyBlIE9OIGUuZW1wbG95ZWVfaWQgPSBwLmVtcGxveWVlX2lkIE9SREVSIEJZIGZpcnN0X25hbWU7\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"> first_name | rating | evaluation_form | form_extension\n<span class=\"hljs-comment\">------------+--------+-----------------+----------------<\/span>\n Alexander  |      5 | alexander.doc   | doc\n Bruce      |      3 | bruce.xls       | xls\n David      |      3 | david.xls       | xls\n Lex        |      3 | lex.pdf         | pdf\n Neena      |      4 | neena.pdf       | pdf<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><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<h2 class=\"wp-block-heading\" id='using-the-right-function-in-the-where-clause'>Using the RIGHT function in the WHERE clause <a href=\"#using-the-right-function-in-the-where-clause\" class=\"anchor\" id=\"using-the-right-function-in-the-where-clause\" title=\"Anchor for Using the RIGHT function in the WHERE clause\">#<\/a><\/h2>\n\n\n\n<p>The following statement uses the <code>RIGHT<\/code> function in the <code><a href=\"https:\/\/www.sqltutorial.org\/sql-where\/\">WHERE<\/a><\/code> clause to find evaluation forms with the extension is <code>pdf<\/code> or <code>xls<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" 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  first_name,\n  rating,\n  evaluation_form,\n  <span class=\"hljs-keyword\">RIGHT<\/span>(evaluation_form, <span class=\"hljs-number\">3<\/span>) form_extension\n<span class=\"hljs-keyword\">FROM<\/span>\n  performance_evaluations p\n  <span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span> employees e <span class=\"hljs-keyword\">ON<\/span> e.employee_id = p.employee_id\n<span class=\"hljs-keyword\">WHERE<\/span>\n  <span class=\"hljs-keyword\">RIGHT<\/span>(evaluation_form, <span class=\"hljs-number\">3<\/span>) <span class=\"hljs-keyword\">IN<\/span> (<span class=\"hljs-string\">'pdf'<\/span>, <span class=\"hljs-string\">'xls'<\/span>)\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span>\n  first_name;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><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><a href=\"https:\/\/www.sqltutorial.org\/playground\/?q=U0VMRUNUIGZpcnN0X25hbWUsIHJhdGluZywgZXZhbHVhdGlvbl9mb3JtLCBSSUdIVChldmFsdWF0aW9uX2Zvcm0sIDMpIGZvcm1fZXh0ZW5zaW9uIEZST00gcGVyZm9ybWFuY2VfZXZhbHVhdGlvbnMgcCBJTk5FUiBKT0lOIGVtcGxveWVlcyBlIE9OIGUuZW1wbG95ZWVfaWQgPSBwLmVtcGxveWVlX2lkIFdIRVJFIFJJR0hUKGV2YWx1YXRpb25fZm9ybSwgMykgSU4gKCdwZGYnLCAneGxzJykgT1JERVIgQlkgZmlyc3RfbmFtZTs%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"> first_name | rating | evaluation_form | form_extension\n<span class=\"hljs-comment\">------------+--------+-----------------+----------------<\/span>\n Bruce      |      3 | bruce.xls       | xls\n David      |      3 | david.xls       | xls\n Lex        |      3 | lex.pdf         | pdf\n Neena      |      4 | neena.pdf       | pdf<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><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<h2 class=\"wp-block-heading\" id='using-the-right-function-with-an-aggregate-function'>Using the RIGHT function with an aggregate function <a href=\"#using-the-right-function-with-an-aggregate-function\" class=\"anchor\" id=\"using-the-right-function-with-an-aggregate-function\" title=\"Anchor for Using the RIGHT function with an aggregate function\">#<\/a><\/h2>\n\n\n\n<p>The following query uses the <code>RIGHT<\/code> function with the <code><a href=\"https:\/\/www.sqltutorial.org\/sql-aggregate-functions\/sql-count\/\">COUNT<\/a><\/code> aggregate function to get the count for each form extension:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" 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  <span class=\"hljs-keyword\">RIGHT<\/span>(evaluation_form, <span class=\"hljs-number\">3<\/span>) form_extension,\n  <span class=\"hljs-keyword\">COUNT<\/span>(*) extension_count\n<span class=\"hljs-keyword\">FROM<\/span>\n  performance_evaluations\n<span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span>\n  <span class=\"hljs-keyword\">RIGHT<\/span>(evaluation_form, <span class=\"hljs-number\">3<\/span>)\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span>\n  form_extension;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><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><a href=\"https:\/\/www.sqltutorial.org\/playground\/?q=U0VMRUNUIFJJR0hUKGV2YWx1YXRpb25fZm9ybSwgMykgZm9ybV9leHRlbnNpb24sIENPVU5UKCopIGV4dGVuc2lvbl9jb3VudCBGUk9NIHBlcmZvcm1hbmNlX2V2YWx1YXRpb25zIEdST1VQIEJZIFJJR0hUKGV2YWx1YXRpb25fZm9ybSwgMykgT1JERVIgQlkgZm9ybV9leHRlbnNpb247\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"> form_extension | extension_count\n<span class=\"hljs-comment\">----------------+-----------------<\/span>\n doc            |               1\n pdf            |               2\n xls            |               2<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><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<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the <code>RIGHT<\/code> function to extract a specified number of characters from the end of a string.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id='databases'>Databases <a href=\"#databases\" class=\"anchor\" id=\"databases\" title=\"Anchor for Databases\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.pgtutorial.com\/postgresql-string-functions\/postgresql-right\/\" target=\"_blank\" rel=\"noreferrer noopener\">PostgreSQL RIGHT Function<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-right-function\/\" target=\"_blank\" rel=\"noreferrer noopener\">MySQL RIGHT Function<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.db2tutorial.com\/db2-string-functions\/db2-right\/\" target=\"_blank\" rel=\"noreferrer noopener\">Db2 RIGHT Function<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-string-functions\/sql-server-right-function\/\" target=\"_blank\" rel=\"noreferrer noopener\">SQL Server RIGHT Function<\/a><\/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=\"3121\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqltutorial.org\/sql-string-functions\/sql-right\/\"\n\t\t\t\tdata-post-title=\"SQL RIGHT 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=\"3121\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqltutorial.org\/sql-string-functions\/sql-right\/\"\n\t\t\t\tdata-post-title=\"SQL RIGHT 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>In this tutorial, you&#8217;ll learn how to use the SQL RIGHT function to return a specified number of characters from the end of a string.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1080,"menu_order":13,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-3121","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SQL RIGHT Function<\/title>\n<meta name=\"description\" content=\"In this tutorial, you&#039;ll learn how to use the SQL RIGHT function to return a specified number of characters from the end of a string.\" \/>\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.sqltutorial.org\/sql-string-functions\/sql-right\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL RIGHT Function\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you&#039;ll learn how to use the SQL RIGHT function to return a specified number of characters from the end of a string.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqltutorial.org\/sql-string-functions\/sql-right\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-04T13:55:41+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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqltutorial.org\/sql-string-functions\/sql-right\/\",\"url\":\"https:\/\/www.sqltutorial.org\/sql-string-functions\/sql-right\/\",\"name\":\"SQL RIGHT Function\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqltutorial.org\/#website\"},\"datePublished\":\"2025-01-27T13:02:37+00:00\",\"dateModified\":\"2025-02-04T13:55:41+00:00\",\"description\":\"In this tutorial, you'll learn how to use the SQL RIGHT function to return a specified number of characters from the end of a string.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.sqltutorial.org\/sql-string-functions\/sql-right\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqltutorial.org\/sql-string-functions\/sql-right\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqltutorial.org\/sql-string-functions\/sql-right\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqltutorial.org\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL String Functions\",\"item\":\"https:\/\/www.sqltutorial.org\/sql-string-functions\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"SQL RIGHT Function\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqltutorial.org\/#website\",\"url\":\"https:\/\/www.sqltutorial.org\/\",\"name\":\"SQL Tutorial\",\"description\":\"An Interactive SQL Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqltutorial.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":"SQL RIGHT Function","description":"In this tutorial, you'll learn how to use the SQL RIGHT function to return a specified number of characters from the end of a string.","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.sqltutorial.org\/sql-string-functions\/sql-right\/","og_locale":"en_US","og_type":"article","og_title":"SQL RIGHT Function","og_description":"In this tutorial, you'll learn how to use the SQL RIGHT function to return a specified number of characters from the end of a string.","og_url":"https:\/\/www.sqltutorial.org\/sql-string-functions\/sql-right\/","og_site_name":"SQL Tutorial","article_modified_time":"2025-02-04T13:55:41+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqltutorial.org\/sql-string-functions\/sql-right\/","url":"https:\/\/www.sqltutorial.org\/sql-string-functions\/sql-right\/","name":"SQL RIGHT Function","isPartOf":{"@id":"https:\/\/www.sqltutorial.org\/#website"},"datePublished":"2025-01-27T13:02:37+00:00","dateModified":"2025-02-04T13:55:41+00:00","description":"In this tutorial, you'll learn how to use the SQL RIGHT function to return a specified number of characters from the end of a string.","breadcrumb":{"@id":"https:\/\/www.sqltutorial.org\/sql-string-functions\/sql-right\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqltutorial.org\/sql-string-functions\/sql-right\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqltutorial.org\/sql-string-functions\/sql-right\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqltutorial.org\/"},{"@type":"ListItem","position":2,"name":"SQL String Functions","item":"https:\/\/www.sqltutorial.org\/sql-string-functions\/"},{"@type":"ListItem","position":3,"name":"SQL RIGHT Function"}]},{"@type":"WebSite","@id":"https:\/\/www.sqltutorial.org\/#website","url":"https:\/\/www.sqltutorial.org\/","name":"SQL Tutorial","description":"An Interactive SQL Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqltutorial.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/pages\/3121","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/comments?post=3121"}],"version-history":[{"count":0,"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/pages\/3121\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/pages\/1080"}],"wp:attachment":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/media?parent=3121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}