Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to get min and max rowcoun of a column for every row
    primarykey
    data
    text
    <p>I would like to get max and min value in one row from one table </p> <p>For example, I have the following rows in table a:</p> <pre><code>Insert into TABLE1 (TRADE_DATE, COL_NAME, COL_VALUE, REC_COUNT) Values (TO_DATE('12/08/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'STOCK_SYM', 'A', 1210885); Insert into TABLE1 (TRADE_DATE, COL_NAME, COL_VALUE, REC_COUNT) Values (TO_DATE('12/08/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'STOCK_SYM', 'AA', 1211091); Insert into TABLE1 (TRADE_DATE, COL_NAME, COL_VALUE, REC_COUNT) Values (TO_DATE('12/08/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'STOCK_SYM', 'AAAA', 9); Insert into TABLE1 (TRADE_DATE, COL_NAME, COL_VALUE, REC_COUNT) Values (TO_DATE('12/08/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'STOCK_SYM', 'AAAE', 1); Insert into TABLE1 (TRADE_DATE, COL_NAME, COL_VALUE, REC_COUNT) Values (TO_DATE('12/08/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'STOCK_SYM', 'AABVF', 11); Insert into TABLE1 (TRADE_DATE, COL_NAME, COL_VALUE, REC_COUNT) Values (TO_DATE('12/08/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'STOCK_SYM', 'AAC', 916); Insert into TABLE1 (TRADE_DATE, COL_NAME, COL_VALUE, REC_COUNT) Values (TO_DATE('12/08/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'STOCK_SYM', 'AACAY', 2); Insert into TABLE1 (TRADE_DATE, COL_NAME, COL_VALUE, REC_COUNT) Values (TO_DATE('12/08/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'STOCK_SYM', 'AACC', 2469); Insert into TABLE1 (TRADE_DATE, COL_NAME, COL_VALUE, REC_COUNT) Values (TO_DATE('12/08/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'STOCK_SYM', 'AACOU', 66); </code></pre> <p>i would like to get the results as below</p> <pre><code>col_val1 max_val col_val2 min_val -------- ------- -------- ------ AA 1211091 AAAE 1 A 1210885 AACAY 2 AACC 2496 AAAA 9 AAC 916 AABVF 11 AACOU 66 AACOW 56 </code></pre> <p>I tried <code>min(col_value) over (partition by trade_date order by rec_count)</code> but I only can get either min or max. When I create two tables, one with min and another with max, and select from it, I get a Cartesian join.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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