Search code examples
oracle11gcognos-10

How to reverse the Lastname,Firstname of an expression inside a Cognos data item?


I created a list report in Cognos and the LAST NAME column is currently in Lastname,Firstname order, with no spaces except for Firstname with a second name included.

From this current set-up

    LAST_NAME COLUMN
    Morello,Mortel     
    Chopra,Deepak      
    Fothergill,Mike Edward   
    Smith,David        

I'm hoping to get this result.

    NEW DATA ITEM
    Mortel Morello
    Deepak Chopra
    Mike Edward Fothergill
    David Smith

I tried using a substring function but it does not work.

substring(LAST_NAME, position(',', LAST_NAME)+1, 
inStr(LAST_NAME, ' ',position(',', LAST_NAME)+1, 1))

Solution

  • This should work:

    substring([Last Name],position(',',[Last Name])+1) 
    + ' ' +
    substring([Last Name],1,position(',',[Last Name])-1)