Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL - Combine multiple columns into one column with more rows
    text
    copied!<p>I have a table with 20 columns that all display the same thing. I'm not sure why my company set it up like this, but I cannot make changes to the table.</p> <p>With that in mind, here is what I need to do. I need to populate a drop down list with insurance company names. Therefore I need to find unique values across the entire table.</p> <p>Using a <code>Group By</code> clause is out of the question because I need unique values across the entire table. No single column contains all the possible values. My only thought was to combine all the columns of the table together. I've seen this done using two pipes ( || ). But that concatenates the columns which does not help me.</p> <p>I need to join two (or twenty) columns together and add their rows together. I.e. if I started out with 20 columns and 100 rows, I need to have one column with 2000 rows. This way I can select unique values using the Group By clause.</p> <p>Any help would be greatly appreciated!</p> <p>Sample of what I'm trying to accomplish:</p> <p>Sample original table:</p> <pre><code> --Ins1-----Ins2---Ins3---Ins4- Medicaid-Medicare------------- ---------Medicaid-----No 485-- Blue Cross-------------------- -------Home Health----Medicare </code></pre> <p>Table I need to construct:</p> <pre><code> --Column1-- -Medicaid-- ----------- Blue Cross- ----------- -Medicare-- -Medicaid-- ----------- Home Health ----------- ----------- ----------- ----------- ----------- --No 485--- ----------- -Medicare-- </code></pre> <p>Maybe my logic is wrong. This is the only way I could see to find unique information across the entire table.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload