sql - Can I order by rank or dense rank in ntile function? -


i looking in regards finding out whether can use rank/dense rank function within ntile query.

i have following code have written:

ntile(5) on (partition job_type order score desc) m_ntile ,dense_rank() on (partition month_ending, job_type order m_ntile desc) rank 

but want instead of order score in ntile ordered results in rank query.

is possible? if please advise appreciate it.

you need use subquery:

select t.*,        dense_rank() on (partition month_ending, job_type                           order m_ntile desc) rank (select . . .,              ntile(5) on (partition job_type order score desc) m_ntile       . . .       ) t  

however, doesn't seem necessary. why not use score?

select t.*,        dense_rank() on (partition month_ending, job_type                           order score desc) rank 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -