Quote:
But my concern is how do I from a query something like:
select distinct (col1+col3) , col4,col5,col6.
|
Quote:
|
If col1+col3 is unique, then col1,col3,col4,col5,etc,etc will also be unique so a straight select should do it
|
If (col1+col3) is not unique and
1) col4, col5, col6 are not neccesary selected from same row.
Code:
SELECT col1, col3, MAX(col4), MAX(col5), MAX(col6)
FROM tableX
GROUP BY col1, col3;
2) col4, col5, col6 should be selected from same row.
Code:
SELECT col1, col3, col4, col5, col6
FROM
( SELECT col1, col3, col4, col5, col6
, ROW_NUMBER() OVER(PARTITION BY col1, col3) rn
FROM tableX
) AS x
WHERE rn = 1;