left function

Posted on 2004-11-16
Last Modified: 2012-06-27
how do i do a left function in oracle..
 left([stra],5) =abcde(I would do it this way in vba but inoracle how do i do it

also how do it do multiple if consitions in oracle..
decode works for 1 or 2 but for 10 it does not..
Question by:eileenbanik
    LVL 3

    Accepted Solution

    substr(stra, 1, 5)

    If you are on a recent version of Oracle, you can use the CASE statement for multiple conditions.

    select case
      when x = 1 then ...
      when user = 'XYZ'  then ...
    from ...

    select case empno
      when 1 then ...
      when 2 then ...
    from ...
    LVL 23

    Expert Comment

    Of course decode works for more than 1 or 2 conditions, check this out:

    LVL 23

    Expert Comment

    SQL> select decode(decode(decode(sysdate,'16-NOV-04','OK','NOT OK'),'OK',SYSDATE,SYSDATE-1),SYSDATE,DUMMY,'Y') FROM DUAL;


    Give me 500 points and I'll nest 20 decodes for you...
    LVL 76

    Expert Comment

    by:slightwv (䄆 Netminder)
    >> how do i do a left function in oracle..

    Use substring:
      select 'Got it' from dual where  substr('abcdefghijkl',1,5) = 'abcde';

    >>also how do it do multiple if consitions in oracle.

    Could you provide a little more detail on the specifics of this requirement?

    Author Comment

    All the solutions solve the problem,Thanks to all of You. I would max points to everybodys answer thank you

    Featured Post

    PRTG Network Monitor: Intuitive Network Monitoring

    Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Oracle date format issue 36 80
    Updating a table with store proc - Need a simple example 12 36
    SAP and ODBC links 2 66
    oracle 10G 5 37
    Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
    Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
    Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
    This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now