If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

Transposing undefined values from ROWS into COLUMNS

Hi,

I have been searching for a while and couldn't find any examples/solutions to my problem. I am querying an MS SQL Server database and collecting clients with certain characteristics. I want to have each distinct client as row and all characteristics as columns. Up to here, this is just a simple "flat" query. The problem comes in as one of the client characteristics may have different (1 or more than one) values, and I want them all. Right now my query is displaying each one of these different values for that characteristic as a new instance and thus my clients (rows) aren't distinct. I may have one or more instances for the same client because of the possible different values of that characteristic. In addition, the values for this characteristic could be multiple and more than 100. I am emphasizing this because I saw some examples out there that using a CASE statement create new columns for each different value. However, those values here can't be predetermined into a CASE comparion because they are not known and are many (the are exemplified below with letters). Also, while clients can have more one value for this characteristic, they usually don't have more than 5 different values. So I was thinking of creating 5 new columns and assigning every different value to each one of the columns.