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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to sort only one column in a table

Author  Topic 

divyaram
Posting Yak Master

180 Posts

Posted - 2010-03-04 : 05:36:23
Hi all,


I want sort data in a table first column is in a sort form only, i want to sort second in ascending form irrespective to the first column. How i can do this sorting, is there method in sql server 2008/2005
the table structure will be like this

Name affiliation
App1 Aff-2
App2 Aff-1
App3 Aff 2
App4 Aff1
App5 Aff3
App6 Aff2
APP7 Aff4


Regards,
Divya

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-03-04 : 05:50:33
What is the expected result?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

divyaram
Posting Yak Master

180 Posts

Posted - 2010-03-04 : 06:23:09
quote:
Originally posted by madhivanan

What is the expected result?

Madhivanan

Failing to plan is Planning to fail



The output should be like this




Name affiliation
App1 Aff-1
App2 Aff-1
App3 Aff 2
App4 Aff2
App5 Aff2
App6 Aff3
APP7 Aff4

Regards,
Divya
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-03-04 : 06:33:32
quote:
Originally posted by divyaram

quote:
Originally posted by madhivanan

What is the expected result?

Madhivanan

Failing to plan is Planning to fail



The output should be like this




Name affiliation
App1 Aff-1
App2 Aff-1
App3 Aff 2
App4 Aff2
App5 Aff2
App6 Aff3
APP7 Aff4

Regards,
Divya


Why do you want to do this?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

divyaram
Posting Yak Master

180 Posts

Posted - 2010-03-04 : 06:42:36
quote:
Originally posted by madhivanan

quote:
Originally posted by divyaram

quote:
Originally posted by madhivanan

What is the expected result?

Madhivanan

Failing to plan is Planning to fail



The output should be like this




Name affiliation
App1 Aff-1
App2 Aff-1
App3 Aff 2
App4 Aff2
App5 Aff2
App6 Aff3
APP7 Aff4

Regards,
Divya


Why do you want to do this?

Madhivanan

Failing to plan is Planning to fail




this is an example for a real time scenario... im adding a column values from other table...there i have to display the columns irrespective the relation ...like if affilation column has been added according to the relation with a userid... but i table i have to show all affilation in ascending order...

i think you got my scenario....

Regards,
Divya
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-03-04 : 07:32:57
<<
im adding a column values from other table...
>>

Post the full code you are using

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-04 : 09:01:37
then i think what you need is a change in join to get the columns in order you want. Anyways as Madhi suggested post your full query without which its difficult for us to suggest

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -