> I face issue ican't represent rows as column .<<
Yes, that's exactly right! Rows and columns are totally, completely, different! A row represents an entity which is an element in a set (table) and it is identified by a key (a subset of the columns which is unique). A column in a properly designed table will be a scalar data value that models an attribute of the entity modeled by the row.
> I need to represent code type from details table to display as column with values of countparts <<
Please read ISO 11179 standards. An attribute can be either a "<something>_code" or a <something>_type, but not this weird hybrid. These post fixes are what we call "attribute properties" and an attribute can have one and only one of them. Please take a course on basic data modeling! You're doing everything completely wrong
You are still trying to write SQL as if you were in a procedural language, with a file system and link list. SQL is a declarative, relational, language that is said oriented
I do not wish to post several thousand words again, so please Google "nested set model" and redesign your schema into a real relational database.