Difference between revisions of "RIGHT"

From SQLZOO
Jump to: navigation, search
(Created page with "<table align='right' border='1'> <caption>Compatibility</caption> <tr><th colspan='3'>RIGHT(s,i)</th></tr> <tr><td align='center'>'''Engine'''</td><td align='center'>'''OK'''<...")
 
Line 5: Line 5:
 
<tr><td align='left'>ingres</td><td>Yes</td><td></td></tr>
 
<tr><td align='left'>ingres</td><td>Yes</td><td></td></tr>
 
<tr><td align='left'>mysql</td><td>Yes</td><td></td></tr>
 
<tr><td align='left'>mysql</td><td>Yes</td><td></td></tr>
<tr><td align='left'>oracle</td><td>No</td><td>[[SUBSTR(s, -i)]]</td></tr>
+
<tr><td align='left'>oracle</td><td>No</td><td>[[SUBSTR |SUBSTR(s, -i)]]</td></tr>
<tr><td align='left'>postgres</td><td>No</td><td>[[SUBSTRING(s , 1+LENGTH(s)-i , i)]]</td></tr>
+
<tr><td align='left'>postgres</td><td>No</td><td>[[SUBSTRING |SUBSTRING(s , 1+LENGTH(s)-i , i)]]</td></tr>
 
<tr><td align='left'>sqlserver</td><td>Yes</td><td></td></tr>
 
<tr><td align='left'>sqlserver</td><td>Yes</td><td></td></tr>
 
</table>
 
</table>
Line 36: Line 36:
 
<p>See also</p>
 
<p>See also</p>
 
<ul>
 
<ul>
   <li>[[SUBSTRING function]]</li>
+
   <li>[[SUBSTRING |SUBSTRING function]]</li>
 
   <li>[[LEFT |LEFT function]]</li>
 
   <li>[[LEFT |LEFT function]]</li>
 
   <li>[[POSITION |POSITION function]]</li>
 
   <li>[[POSITION |POSITION function]]</li>
 
</ul>
 
</ul>

Revision as of 15:23, 16 July 2012

Compatibility
RIGHT(s,i)
EngineOKAlternative
ingresYes
mysqlYes
oracleNoSUBSTR(s, -i)
postgresNoSUBSTRING(s , 1+LENGTH(s)-i , i)
sqlserverYes

RIGHT

RIGHT(s,n) allows you to extract n characters from the end of the string s.

   RIGHT('Hello world', 4) -> 'orld'      
SELECT name,
       SUBSTRING(name, 1+LENGTH(name)-3, 3)
  FROM bbc
SELECT name,
       SUBSTR(name, -3)
  FROM bbc
SELECT name,
       RIGHT(name, 3)
  FROM bbc

See also

Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense