Click here to Skip to main content
15,881,725 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HI i need a query for this table

-----------------------------------
id        name       datestart            endStart         coursid
1         ali        2012/02/02            2012/06/02         1010
02        amir       2012/02/03            2012/03/03         2020
3         saeed      2012/02/05            2012/03/20         8020
4         amir       2012/05/06            2012/06/20         2020
5         reza       2012/01/05            2012/01/09         9090
6         amir       2013/02/03            2013/03/03         2020
7         amir       2014/02/03            2014/03/03         2020
.
.

iam need this result
name       datestart            endStart         coursid      stage
amir       2012/02/03            2012/03/03         2020        1
amir       2012/05/06            2012/06/20         2020        2
amir       2013/02/03            2013/03/03         2020        3
amir       2014/02/03            2014/03/03         2020        4

how need filed stage
Posted
Updated 6-Sep-14 1:09am
v2

SQL
SELECT  
    name,
    datestart,
    endStart,
    coursid,
    ROW_NUMBER() OVER (ORDER BY name) stage
FROM    
    tableName
 
Share this answer
 
v2
SQL
 SELECT  name, datestart, endStart, coursid, ROW_NUMBER() OVER (ORDER BY name) stage
 FROM table_Name
where name='amir'
 
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