Click here to Skip to main content
15,890,995 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Need that
Select SQL ROW
as SQL COLUMNS

Example

SQL
Select
      ProductCode,
      CustomerCode,
      Sum(SALEQTY)
      from PRODUCTSALE group by ProductCode,CustomerCode

ProductCode CustomerCode	SALEQTY
M503DA    	00000001	1
M503DA    	00000002	1
M503DF    	00000003	1
M503DF    	00000004	3
M502DA    	00000005	1
M510CF    	00000006	1
M502DA    	00000007	1
M502DF    	00000008	9
M503DA    	00000009	1
M503DF    	00000010	8
M502DA    	00000011	5
M510CF    	00000012	1
M503DA    	00000013	1
M503DF    	00000014	1
M510CA    	00000015	2
M515CF    	00000016	1
M502DF    	00000017	1


i need Product code As Columns and Value SALEQTY
what should i do ??
Posted
Updated 20-Jan-15 16:40pm
v2
Comments
[no name] 20-Jan-15 23:18pm    
As per ArunRajendra you can use Pivot for your requirement. If it doesnot fulfill your requirement then please mention your requirement properly so that some one can help you properly.
saimm 20-Jan-15 23:25pm    
but how product Code select as column
because i dont want to write specific product code becuase it will be change or edit or add
so need smart query
or any dynmaic Query to Select Product code as Columns Names

Select distint(Productcode) from Product

how Select Result of this Query as Columns Names?
saimm 20-Jan-15 23:24pm    
but how product Code select as column
because i dont want to write specific product code becuase it will be change or edit or add
so need smart query
or any dynmaic Query to Select Product code as Columns Names

Select distint(Productcode) from Product

how Select Result of this Query as Columns Names?

1 solution

 
Share this answer
 
Comments
saimm 20-Jan-15 22:55pm    
but how product Code select as column
because i dont want to write specific product code becuase it will be change or edit or add
so need smart query

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900