hi
you can try using row_number function

select Subject ,row_number() (OVER PARTITION BY subject ORDER BY grade)
"rownumber" from tab1;

note: The above query was not tested.

2009/7/5 Vlad <vladimir.mcbad...@gmail.com>

>
> I'm hoping someone can help me with a technique to add a rownumber in
> a different way to the simple use of it.
>
> I have a data table that looks like this
>
> Subject Name    Grade
> English Tom     A
> English Paul    A
> English James   B
> Maths   Tom     B
> Maths   Paul    D
> Maths   James   A
> Science Tom     C
> Science Paul    D
>
>
> I want to add a rownumber that restarts on each new subject - here is
> a sample how I am trying to get ther results.
>
> Subject         RowNumber       Name    Grade
> English         1               Tom     A
> English         2               Paul    A
> English         3               James   B
> Maths           1               Tom     B
> Maths           2               Paul    D
> Maths           3               James   A
> Science         1               Tom     C
> Science         2               Paul    D
>
> TIA
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Oracle PL/SQL" group.
To post to this group, send email to Oracle-PLSQL@googlegroups.com
To unsubscribe from this group, send email to
oracle-plsql-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/Oracle-PLSQL?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to