The value-based sequential query

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
  

Poston Tue, 14 Mar 2006 2:13 pm

How to make a sequence based on the value of the query?

example, I have a query which returns: date----------1/1/2006 1/1/2006 1/1/2006 1/1/2006 2/2/2006 2/2/2006 2/2/2006 2/2/2006 do return DATE SEQ-------------------------1 1/1/2006 1/1/2006 2 1/1/2006 3 1/1/2006 4 2/2/2006 2/2/2006 2/2/2006 2/2/2006 1 2 3 4 valeu!

[] 's
MuLtAnI
Location: Videira - SC


Poston Tue, 14 Mar 2006 3:09 pm

Take a look at this example of scott:
Code: Select all
SELECT deptno, ename, sal ,
  ROW_NUMBER()
    OVER (PARTITION BY deptno
          ORDER BY ENAME) "Seq"
FROM emp
ORDER BY deptno, ename
here's his response:
Code: Select all
SQL> SELECT deptno, ename, sal ,
  2    ROW_NUMBER()
  3      OVER (PARTITION BY deptno
  4            ORDER BY ENAME) "Seq"
  5  FROM emp
  6  ORDER BY deptno, ename
  7  /

    DEPTNO ENAME             SAL        Seq
---------- ---------- ---------- ----------
        10 CLARK            2450          1
        10 KING             5000          2
        10 MILLER           1300          3
        20 ADAMS            1100          1
        20 FORD             3000          2
        20 JONES            2975          3
        20 SCOTT            3000          4
        20 SMITH             800          5
        30 ALLEN            1600          1
        30 BLAKE            2850          2
        30 JAMES             950          3
        30 MARTIN           1250          4
        30 TURNER           1500          5
        30 WARD             1250          6

14 rows selected.

SQL>
take a look at this topic about analytic functions: viewtopic.php?p=2028:-
dr_gori
Location: Portland, OR USA

Thomas F. G

Você já respondeu a dúvida de alguém hoje?
http://glufke.net/oracle/search.php?search_id=unanswered


  • See also
    Replies
    Views
    Last Post


    Return to SQL

    Who is online

    Users browsing this forum: No registered users and 2 guests