KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have written a complex SQL query with Oracle in which I want to use two analytic function over the same partition. Let's be quite simple but not too much: SELECT col1, MAX(col2) OVER(PARTITION BY col3, col4, col5, col6, CASE WHEN col7 LIKE 'foo' THEN SUBSTR(col7,1,5) ELSE col7 END ORDER BY col5 ASC, col6 DESC), MIN(col2) OVER(PARTITION BY col3, col4, col5, col6, CASE WHEN col7 LIKE 'foo' THEN SUBSTR(col7,1,5) ELSE col7 END ORDER BY col5 ASC, col6 DESC) FROM my_table; Is there a more elegant syntax for factoring the PARTITION BY clause? Thank you.
Tags (comma-separated)
Save Edits
Cancel