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 |
|
goligol
Posting Yak Master
128 Posts |
Posted - 2011-06-17 : 16:37:56
|
| Hi,I have created view which only has one column, I would like to order the rows ascending based on the value in the column and also add another column (OGH) and fill the new column from 1 to the size of the rows after setting the first column ascending.Here is my view where I want to add to order it and add to it another column with number from 1.ALTER view [dev].[OG]asSELECT [geo_orig] OG FROM [bts].[dev].[geo_master]GO |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-06-17 : 16:50:58
|
| ALTER view [dev].[OG] asSELECT TOP 100 PERCENT [geo_orig] OG, ROW_NUMBER() OVER (ORDER BY [geo_orig]) OGHFROM [bts].[dev].[geo_master]ORDER BY [geo_orig] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-06-20 : 10:50:14
|
| In the original VIEW, you can query it likeSELECT OG,ROW_NUMBER() OVER (ORDER BY [OG]) OGHFROM OGORDER BY OGHMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|