Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
abhi234u
Starting Member
1 Post |
Posted - 2010-04-30 : 10:43:08
|
| Hi there,We have a small view to create. I have columnsYear Month recordnumber County sales revenue2008 jan 12345 xyz $1002008 Feb 12345 TRW $200I have to adda new column which shows unique recordnumber's. It should show 1 for jan, 0 for february and so on.Any inputs would be appreciated.ThanksAbhi |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-04-30 : 10:48:08
|
| Is this?select row_number() over (order by year) as sno, * from your_tableMadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-05-01 : 04:23:22
|
or this?select row_number() over (partition by year order by case Month when 'Jan' then 1 when 'Feb' then 2 ....when 'Dec' then 12 end asc) as sno, * from your_table ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-07 : 03:37:09
|
| orselect row_number() over (order by month+cast(year as varchar(4))) as sno, * from your_tableMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|