Db2 query with between and partition by

0

I need a help with this query below, it is not doing what I like. She makes everything perfect. But when I use the between it returns an error. I would like an help on the query.

SELECT UNIDADE, MATRICULA, NOME, CURSO, ESCOLA, DTATU, HRATU, STATUS,ROW_NUMBER() OVER(ORDER BY NOME ) AS CONT
FROM (

SELECT *
FROM (SELECT ROW_NUMBER() OVER (PARTITION BY MATRICULA ORDER BY DTATU DESC,HRATU DESC) AS RN,   
row_number() OVER ( ORDER BY NOME ) AS rid, UNIDADE, MATRICULA, NOME, CURSO, ESCOLA, DTATU, HRATU, STATUS 
FROM MOV_PROTOCOLO WHERE MATRICULA!='' ) AS t WHERE MATRICULA!=''and RN = 1) WHERE V.CONT BETWEEN 0 AND 10

Something like this:

PLACE   CODE      STATUS CONT                 
------- --------- ------ -------------------- 
001     41309014  OK     1                    
001     31121810  OK     2                    
001     41309634  OK     3                    
001     31414303  OK     4                    
001     41461487  OK     5                    
001     41207203  OK     6                    
001     41444868  OK     7                    
001     31344046  OK     8                    
001     41447131  OK     9                    
001     41083326  OK     10
    
asked by anonymous 20.01.2015 / 00:09

0 answers