Rows to column

Hello,

Below is the query which currently returns data as shown below:

Current Format:                  
WFC	                        559403	0	  204
WFC	                        559403	1012	  0
XXX	                        1000	1	  0
XXX	                        1000	0	  4

Open in new window

How should I modify this query to get the data in the format as shown below?
WFC	                        559403	1012	     204
XXX	                        1000	1	     4

Open in new window


SELECT  c.company_code,
            c.user_id,
            TO_CHAR(NVL(v_Count_700,0))                         v_Count_700,
            TO_CHAR(NVL(v_Count_704,0) +  NVL(v_Count_705,0))   v_Cosolidated_Count_1
    FROM    (SELECT  b.company_code,
                     b.user_id,
                     b.type,
                     CASE WHEN type = '700' THEN COUNT(*) END v_Count_700,
                     CASE WHEN type = '704' THEN COUNT(*) END v_Count_704,
                     CASE WHEN type = '705' THEN COUNT(*) END v_Count_705                      
               FROM  (SELECT a.company_code,
                             a.user_id,
                             a.type
                        FROM a_log a ,
                             type_mvw t
                       WHERE a.type = t.type
                         AND t.type IN ('700','704','705')
                      ) b
             GROUP BY b.company_code,
                      b.user_id,
                      b.type
            )c;

Thanks!

sath350163Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
Add a max.  Pasted on mobile.  Might have typos.

SELECT  c.company_code,
            c.user_id,
            max(TO_CHAR(NVL(v_Count_700,0)))                         v_Count_700,
            max(TO_CHAR(NVL(v_Count_704,0) +  NVL(v_Count_705,0)))   v_Cosolidated_Count_1

...
Group by company_code, user_id
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sath350163Author Commented:
Thanks slightwv.
Your solution worked perfectly.
0
sath350163Author Commented:
Solution to convert individual rows to individual columns on the same row
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.