sql - Combining multiple rows into one row where the data in only one column changes and adding the data for the varied column onto the end of the row -
sql - Combining multiple rows into one row where the data in only one column changes and adding the data for the varied column onto the end of the row -
i hoping help me sql basic. below query:
i have info looks this:
policy number | commission amount | relationship | personlinked 50422 | 1000.00 | owner | john smith 50422 | 1000.00 | advisor | richard bass 50422 | 1000.00 | port man | craig thomson 74857 | 500.00 | owner | karen jones 98765 | 20000.00 | owner | tim crosby 98765 | 20000.00 | port man | josh bishop
but want display of info in 1 row looks this:
policy number | commission amount | owner | advisor | port man 50422 | 1000.00 | john smith | richard bass | craig thomson 74857 | 500.00 | karen jones | | 98765 | 20000.00 | tim crosby | | josh bishop
if possible manipulate info in way, please allow me know sql be. stuck. please help.
unless there fixed, static number of relationships, known beginning, reply is: no. cannot create sql queries homecoming variable number of columns.
your chances are: - if using proprietary sql rdbms, there might pivoting functionality - if using kind of language (like php, vba) create query - can create in dynamically, after querying possible relationships.
sql
Comments
Post a Comment