Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After digging out we will find numerous similar questions, I can systemtically state the answer as follow:<br> 1. In order to transpose columns to rows, you may use <code>UNION ALL</code> <a href="https://stackoverflow.com/questions/3802219/transpose-columns-to-rows">here</a><br> 2. In order to apply PIVOT table you should consider oracle version as follow:<br> a. Oracle 11g: You can use <a href="http://www.oracle.com/technetwork/articles/index.html" rel="nofollow noreferrer">Built In PIVOT Feature</a> and <a href="https://stackoverflow.com/questions/10929108/rotate-pivot-table-with-aggregation-in-oracle">here</a><br> b. Oracle 10g and 9i: You are restricted to use <code>[CASE WHEN][4]</code> expression or <code>[DECODE][5]</code> expression. c. Oracle 8i: You are restricted to use <code>DECODE</code> expression </p> <p>For my question above, I found the solution as follow: </p> <p><code>SELECT uom.code, MAX(CASE WHEN l.language_id = 25 THEN uomt.description ELSE NULL END) AS english, MAX(CASE WHEN l.language_id = 22 THEN uomt.description ELSE NULL END) AS german FROM unit_of_measure uom INNER JOIN unit_of_measure_trans uomt ON (uom.unit_of_measure_id = uomt.unit_of_measure_id) INNER JOIN language l ON (uomt.language_id = l.language_id) WHERE l.language_id IN (25, 22)) GROUP BY uom.code;</code> </p> <p>Notice that in <code>CASE WHEN</code> expression, if you do not use aggregate function you'll get error unless you remove <code>GROUP BY</code> expression. However, in the later case, you'll get all null values which is rarely useful result</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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