Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Posts
    14

    Unanswered: help in SQL function

    Can anyone help in DB2 SQL?

    DEPT_ID(CHAR data type)
    2000
    2100
    2200_ABC
    2300_CDE
    2400_FGH

    I need only numerics to be displayed(all characters aftre underscore should be truncated)?TRUNCATE does'nt work.

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1

    Re: help in SQL function

    Originally posted by mark_tim1999
    Can anyone help in DB2 SQL?

    DEPT_ID(CHAR data type)
    2000
    2100
    2200_ABC
    2300_CDE
    2400_FGH

    I need only numerics to be displayed(all characters aftre underscore should be truncated)?TRUNCATE does'nt work.
    SUBSTR(DEPT_ID,1,5)

    or

    CASE
    LOCATE(DEPT_ID, '_')
    WHEN 0
    DEPT_ID
    ELSE
    SUBSTR(DEPT_ID, 1, LOCATE(DEPT_ID, '_'))
    END

  3. #3
    Join Date
    Dec 2003
    Posts
    14
    Thanks n_i

Posting Permissions

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