Distinct select on Oracle
Posted
by
funktku
on Stack Overflow
See other posts from Stack Overflow
or by funktku
Published on 2010-12-23T23:12:30Z
Indexed on
2010/12/23
23:54 UTC
Read the original article
Hit count: 185
What i am trying to do is a simple recommender , must take the biggest weighted top 40 element's node2 element. Calculation for weight comes from (E.WEIGHT * K.GRADE)
. Now this code succesfully returns top 40 elements. However, i don't want E.NODE2
to return duplicates. POSTGRE SQL allowed me to do SELECT DISTINCT ON (NODE2) E.NODE2 , (E.WEIGHT * K.GRADE)
. How can i do the same in oracle?
The complete sql query;
SELECT *
FROM (SELECT DISTINCT E.NODE2 , (E.WEIGHT * K.GRADE)
FROM KUAISFAST K, EDGES E
WHERE K.ID = 1 AND K.COURSE_ID = E.NODE1 AND E.NODE2 NOT IN(
SELECT K2.COURSE_ID
FROM KUAISFAST K2
WHERE K2.ID = 1
)
ORDER BY( E.WEIGHT * K.GRADE ) DESC) TEMP
WHERE rownum <= 40
© Stack Overflow or respective owner