Changing output

  • I have the following code:

     

    drop table #temp

    select 'L' as RECTYPE, identity(int, 1, 1)as JELINENO, '800002' as JENO, 'AJE' as JECODE,

    '2006' as FY, '7' as PD, '1' as SUBPD, 'Journal Entry from MAXIMO' as HEADDESC,

    linecost as AMOUNT, issuetype, gldebitacct, glcreditacct

    into #temp

    from matusetrans 

    where it1 <> 'Y' or it1 is null

    and issuetype in ('ISSUE', 'RETURN')

    and storeloc in ('B631OT', 'B642GB', 'B641GB', 'B681AS', 'B681BS', 'B681CA', 'B681SP')

    go

    select * from #temp

     

    I want to combine the gldebitacct and glcreditacct columns into one column named ACCOUNT.  If there is information in the gldebitacct column I want to ignore the glcreditacct information and vice versa.  In additionm if the first 6 characters of either column equal '700048' I want to display '40700-407-00' in the new ACCOUNT column and if the first 6 characters equal '011195' I want to display '60400-66-00' in the new ACCOUNT column.  If the gldebitacct or glcreditacct columns first 6 characters equal any other number I want to generate an error and continue.  Can anyone help with this?

     

    Thanks,

     

    Dave

  • you can accomplish that with the case statement

    ,case

    WHEN gldebitacct IS NOT NULL THEN

         CASE

               WHEN ...

     

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply