Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Sorting Issue

$
0
0

Below is the result set that I am currently displaying 

Order_by

Country

Capital

Continent

8

United States

Washington

North America

20

Australia

Canberra

Australia

5

Russia

Moscow

Europe

77

Canada

Ottawa

North America

88

Denmark

Copenhagen

Europe

288

Iraq

Baghdad

Asia

165

Japan

Tokyo

Asia

3

China

Shanghai

Asia

50

New Zealand

Auckland

Australia

90

Nigeria

Lagos

Africa

The columns Country,Capital and Continent as all sortable columns where users can sort them either in ascending or descending order. But at the same time I want the value in  order by column updated as well. Lets say If I sort Country in ascending order then the resultset should look like this:

Order_by

Country

Capital

Continent

3

Australia

Canberra

Australia

5

Canada

Ottawa

North America

8

China

Shanghai

Asia

20

Denmark

Copenhagen

Europe

50

Iraq

Baghdad

Asia

77

Japan

Tokyo

Asia

88

New Zealand

Auckland

Australia

90

Nigeria

Lagos

Africa

165

Russia

Moscow

Europe

288

United States

Washington

North America

 and same is the case of other columns. sorting any column also sorts and updates the value in order_by column.  I am using a simple store procedure to display the above resultset. So I think I need to make changes in the store procedure to achieve this goal. Or if some 1 else have a better solution then please share the code. I would be very grateful



Viewing all articles
Browse latest Browse all 23857

Trending Articles