How to get first two characters of a string in oracle query?

SUBSTR (documentation):

SELECT SUBSTR(OrderNo, 1, 2) As NewColumnName from shipment

When selected, it's like any other column. You should give it a name (with As keyword), and you can selected other columns in the same statement:

SELECT SUBSTR(OrderNo, 1, 2) As NewColumnName, column2, ... from shipment

take a look here

SELECT SUBSTR('Take the first four characters', 1, 4) FIRST_FOUR FROM DUAL;

Easy:

SELECT SUBSTR(OrderNo, 1, 2) FROM shipment;

select substr(orderno,1,2) from shipment;

You may want to have a look at the documentation too.

Tags:

Sql

Oracle