Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2005
    Posts
    3

    Lightbulb Unanswered: Query output based on substring

    I have an Oracle table with some values containing a hyphen. However, for reporting purposes, I want to group these together in a query result to show them as one entity. Here is what I mean.

    HTML Code:
    I have output:
    
    [U]Items  [/U]        [U]Sums  [/U] 
    Item100         200
    Item200-01      100
    Item200-02      300
    Item400         10
    
    I WANT this:
    
    [U]Items  [/U]        [U]Sums  [/U] 
    Item100        200
    Item200        400
    Item400        10
    Any help would be appreciated!!!

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool



    This is a simple query, did you try coding something yet?

    HINT: Select SUBSTR(), SUM() From MyTable GROUP BY ...

    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Sep 2005
    Posts
    3

    Talking

    OK -
    The following query returns all 3 digit numbers without the hyphenated extension.

    SELECT SUBSTR(a.Item,1,4) "Substring"
    FROM schema.Table a;

    However, this is a problem because some Items have four digits and then a hyphen, such as Item1002-01.

    Ideas?

  4. #4
    Join Date
    Oct 2002
    Location
    greenwich.ct.us
    Posts
    279
    Quote Originally Posted by wolf3341
    Ideas?
    instr(field,'-',-1)

Posting Permissions

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