I have a question in groups to help decode and case in pl/sql

my request is something like this but with more column in select. When I shot this request it gives result but it's not good

My problem is, as if there are more than 3 values for uh.sflowtype (0,1,2) then group by does not work for them and those coming in different line, I need them to be combined

query is:
Select substr (uh.sstartdatetime, 1, 8) DateTime,
(case
When uh.sflowtype = 7 then "sms".
When uh.sflowtype = 9 then 'mms'
When uh.sflowtype = 10 then "gprs".
another "voice".
end)
as e_vpn_usagehistory flowtype UH where 1 = 1 and uh.nspid = '1' AND ((substr (uh.sstartdatetime, 1, 8) > = 20130507))
AND (substr (uh.sstartdatetime, 1, 8) < = 20130606)) GROUP BY substr (uh.sstartdatetime, 1, 8), uh.sflowtype
substr(uh.sstartdatetime,1,8) DESC order


result:

DATETIME FLOWTYPE
-------- --------
20130507 voice
20130507 voice
20130507 voice
20130507 sms
20130507 mms


but I need

20130507 voice
20130507 sms
20130507 mms

so, what should I do?
Please suggest me
select  to_char(uh.sstartdatetime,'DD-MON-YY') DateTime
,       ( case when uh.sflowtype=7 then 'sms'
          when uh.sflowtype=9 then 'mms'
          when uh.sflowtype=10 then 'gprs'
          else 'voice'
          end ) as flowtype
from   e_vpn_usagehistory uh
where uh.nspid='1'
AND   ((substr(uh.sstartdatetime,1,8) >= 20130507 )
AND   (substr(uh.sstartdatetime,1,8) <= 20130606))
GROUP BY to_char(uh.sstartdatetime,'DD-MON-YY'),
          ( case
         when uh.sflowtype=7 then 'sms'
        when uh.sflowtype=9 then 'mms'
        when uh.sflowtype=10 then 'gprs'
        else 'voice' end )
order by to_char(uh.sstartdatetime,'DD-MON-YY') DESC

Try this.

If it doesn't work thanks for posting data.

p.s. Your order will be not that useful as a varchar either

Tags: Database

Similar Questions

Maybe you are looking for