SQLTeam.com | Weblogs | Forums

How to represent rows as column from details table?

I work on sql server 2012 i face issue ican't represent rows as column .

i need to represent code type from details table to display as column with

values of countparts

join between master zplid and details zplid is zplid

every zplid have group of code type so instead of represent code type as rows

i will represent it as columns

columns will have header as code type and content column will be countparts

so How to do that please ?
create table #zplidmaster
zplid int,
zplidname nvarchar(50)
insert into #zplidmaster(zplid,zplidname)

 create table #zpliddetails
 zplid int,
 CodeType  int,
 CountParts int
 insert into #zpliddetails(zplid,CodeType,CountParts) 

expected result


if it always is going to be 2 records for each zplid ... then min , max

       'SQL Result'
	 , zplid
	 , min (CountParts) 
	 , max(CountParts) 
 group by