values into columns
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: values into columns

  1. #1
    Join Date
    Mar 2001
    Location
    south africa
    Posts
    401

    values into columns

    hello

    how do i change values into columns with out all the the blanks ..
    i have orderunits table(orderid number,value and name are varchar2).
    i tried case stmts and not getting results like below,meaning i get rows multiplied,for example in here i get total 25 rows but i should get total 15 or so

    Code:
    "CASE WHEN  fNAME='Units' then p.value else null END AS unit_name,"

    Code:
    Order_ID	UNIT_NAME	DATE_NAME
    30766600	1	
    30766600		090909
    30766600	1	
    30766600		090909

    any help is much appreciated

    thank you

    Code:
    ORDER_ID	VALUE	NAME
    30766600	090909	Date
    30766600	090909	Date
    30766600	090909	Date
    30766600	090709	Date
    30766600	090709	Date
    30766600	090609	Date
    30766600	090609	Date
    30766600	090509	Date
    30766600	090509	Date
    30766600	090509	Date
    30766600	090409	Date
    30766600	090409	Date
    30766600	090309	Date
    30766600	1	Units
    30766600	1	Units
    30766600	1	Units
    30766600	1	Units
    30766600	1	Units
    30766600	13	Units
    30766600	1	Units
    30766600	2	Units
    30766600	1	Units
    30766600	3	Units
    30766600	1	Units
    30766600	1	Units
    		
    		
    		
    		
    orderid	date	units
    30766600	090909	1
    30766600	090909	1
    30766600	090909	1
    30766600	090709	1
    30766600	090709	1
    30766600	090609	13
    30766600	090609	1
    30766600	090509	2
    30766600	090509	1
    30766600	090509	3
    30766600	090409	1
    30766600	090409	1
    30766600	090309	
    30766600	090409	
    30766600	090409	
    30766600	090309	
    30766600	090409
    Last edited by prodadmin; 03-15-2010 at 09:08 AM. Reason: code1

  2. #2
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,554
    mmmhhh... specs are not clear to me, could you please elaborate?
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  3. #3
    Join Date
    Mar 2001
    Location
    south africa
    Posts
    401
    thanks for looking into

    when i use the case stmt i get lot of blanks

    Code:
    CASE WHEN  fNAME='Units' then p.value else null END AS unit_name,
    CASE WHEN  fNAME='Date' then p.value else null END AS date_name
    like this ..
    Code:
    Order_ID	UNIT_NAME	DATE_NAME
    30766600	1	
    30766600		090909
    30766600	1	
    30766600		090909
    30766600	2	
    30766600	13
    but i am looking for

    Code:
    Order_ID	UNIT_NAME	DATE_NAME
    30766600	1	090909
    30766600	2	090909
    30766600	1	
    30766600	13
    hope this helps

    thanks
    Last edited by prodadmin; 03-15-2010 at 09:26 AM. Reason: code111

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width