Dofactory.com
Dofactory.com
Earn income with your data and sql skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

SQL REVERSE Function

REVERSE returns the specified string value in reversed order.

If the input value is not in string, it will be explicitly cast to string.

Example

#

The example returns a the input string in reverse order..

SELECT REVERSE('Reverse') as 'Reverse',
       REVERSE(12345) as '12345',
       REVERSE('level') as 'level'
Result:  1 record
Reverse 12345 level
esreveR 54321 level

Syntax

Syntax of the REVERSE function.

REVERSE(string)

string -- the string to be reversed.


More Examples

REVERSE with Column

CUSTOMER
Id
FirstName
LastName
City
Country
Phone
Problem: List customer's first names and reversed first names.
SELECT FirstName, REVERSE(FirstName) 
       AS 'Reversed Name'
  FROM Customer
Result:  92 records
FirstName Reversed Name
Paolo oloaP
Pedro ordeP
Marias sairaM
Kyle elyK
Miguel leugiM

You may also like



Last updated on Dec 21, 2023

Earn income with your data and sql skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.