wie zu entschlüsseln, mit mehreren Bedingungen mit gleichen Bedingungen mit diff-Ergebnis

Ich habe eine Frage, wie kann ich auswerten, sql, wenn id=5 im Fall der "Directory Assistance" es sollte erhalten die attr_1 als Ausgang und mit id=5 und "Long-Roaming" sollte es geben, attr_35/60.

sum(decode(id,1,attr_35 / 60,
        5,'Long Roaming',attr_35/60,
        5,'Directory Assistance',attr_1))total


with ce as 
(
select case
    when id = 1 and attr_31 like 'Roam%' 
         then 'A1'
    when id = 5 and attr_30 like 'Dir%' and attr_31 like 'Standard%'
        then 'Directory Assistance'
    when id = 5 and attr_30 like 'Dir%' and attr_31 like 'Roam%'
         then 'Directory Assistance Roaming'
    when id = 5 and attr_30 like 'Long Distance%' and attr_31 like 'Roam%'
        then 'Long Roaming' 
    end usagetype

    , sum(decode(id,1,attr_35 / 60, 5,attr_35/60)) total
    from table
      where ce.account_num in ('A4','A5','A6')

    group by
    case
     when id = 1 and attr_31 like 'Roam%'
        then 'A1'
    when id = 5 and attr_30 like 'Dir%' and attr_31 like 'Standard%'
        then 'Directory Assistance'
    when id = 5 and attr_30 like 'Dir%' and attr_31 like 'Roam%'
        then 'Directory Assistance Roaming'
    when id = 5 and attr_30 like 'Long Distance%'and attr_31 like 'Roam%'
        then 'Long Roaming' 
    end
    )
select usagetype,total from ce
InformationsquelleAutor user3274607 | 2014-11-20
Schreibe einen Kommentar