0

以下のクエリがあります

Select 
case upper(device_model)
        when 'IPHONE' then 'iOS - iPhone'
        when 'IPAD' then 'iOS - iPad'
        when 'IPOD TOUCH' then 'iOS - iPod Touch'
        Else 'Android'
        End As Device_Model,
count(create_dtime) as Installs_Oct17_Oct30
From Player
Where Create_Dtime >= To_Date('2012-Oct-17','yyyy-mon-dd')
And Create_Dtime <= To_Date('2012-Oct-30','yyyy-mon-dd')
Group By Device_Model
Order By Device_Model

これにより、「Android」を読み取る複数の結果行が吐き出されます....各ケースに1つずつ、4つの結果行のみが必要です....したがって、次のようになります。

Device_Model     Installs_Oct17_Oct30
Android            987
iOS - iPad         12003
iOS - iPhone       8563
iOS- iPod Touch    3482
4

2 に答える 2

4

式ではなく、フィールドdevice_modelでグループ化しています。

Select 
case upper(device_model)
    when 'IPHONE' then 'iOS - iPhone'
    when 'IPAD' then 'iOS - iPad'
    when 'IPOD TOUCH' then 'iOS - iPod Touch'
    Else 'Android'
    End As Device_Model,
count(create_dtime) as Installs_Oct17_Oct30
From Player
Where Create_Dtime >= To_Date('2012-Oct-17','yyyy-mon-dd')
And Create_Dtime <= To_Date('2012-Oct-30','yyyy-mon-dd')
Group By
case upper(device_model)
    when 'IPHONE' then 'iOS - iPhone'
    when 'IPAD' then 'iOS - iPad'
    when 'IPOD TOUCH' then 'iOS - iPod Touch'
    Else 'Android'
    End
Order By Device_Model
于 2012-10-31T22:59:35.823 に答える