Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2011
    Posts
    7

    Unanswered: substring a column in a view?

    Hi all,

    perhaps a very triviel question but nethertheless I´m stuck on it. I want to create a view where one of the columns ('branche' a integer) is reduced so its only the first two numbers showing. How to do that?

    I was think something like select branche as substr(branche from 1 for 2) but that dosen´t seem to work.

    Christian

  2. #2
    Join Date
    Oct 2009
    Location
    221B Baker St.
    Posts
    486
    I don't believe an integer may be substringed.

    You might try to cast the integer to a char definition and substring this. . .

  3. #3
    Join Date
    Feb 2011
    Posts
    7
    Thanks,

    I had en idea that I had to use CAST. Could you show me the correct syntax?

    Christian

  4. #4
    Join Date
    Oct 2009
    Location
    221B Baker St.
    Posts
    486
    You might try something like:
    cast( branche as char(10orwhatever))

    and then substr this. . .

  5. #5
    Join Date
    Feb 2011
    Posts
    7
    Thanks.

    Tried something like this:

    branche as substring(cast( branche as char(20))

    in my view but got an syntax error. What is the right syntax?

    Thanks again!

    Christian

  6. #6
    Join Date
    Oct 2009
    Location
    221B Baker St.
    Posts
    486
    Suggest branche should Not be used twice in the statememt.

    Check your documentation for the syntax of how to specify the positions to be substringed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •