Click here to Skip to main content
15,900,815 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI
I have a one table like
SQL
college_code  male female  subject
 101              10   25   AAA
 101              15   11   BBB
 223              15   12   AAA
 223              15   12   BBB
 223              15   12   CCC
 331              11   12   AAA

and i want to record like this
SQL
srno  college_code  male female  subject
  1     101          10   25      AAA
  2     101          15   11      BBB
  1     223          15   12      AAA
  2     223          11   11      BBB
  3     223          13   15      CCC
  1     331          11   12      AAA

how to this possible using row number
Thanks to advance
Posted
Updated 15-Dec-13 20:21pm
v2

Try the below code...
SQL
SELECT
    Rank() over (Partition by college_code Order by college_code, subject) as ranks, college_code, male, female, subject

FROM
    College

Group By
    college_code, male, female, subject

Order by
    college_code asc
 
Share this answer
 
it is possible...
1.write a select query like...
select * from table_name where code='101'
2.check how many row selected
3.selected row + 1

i hope this helps a bit
 
Share this answer
 
Comments
Member 10468587 16-Dec-13 2:20am    
mr.Joy i think it will not work .... let him try this

Select ROW_NUMBER() over(Partition By College_Code order By College_Code), * from tablename
Member 10468587 16-Dec-13 2:20am    
this is me
@
gridview not clearing
An@nd Rajan10 16-Dec-13 2:35am    
i got @gridview not clearing
You can use the following sample code:

SQL
SELECT ROW_NUMBER() OVER (ORDER BY college_code) AS srno, college_code , male, female, subject 
FROM XYZ 
 
Share this answer
 
v2
Use the following Query Dude


select ROW_NUMBER() over(Partition By College_Code order By College_Code), * from tablename
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900