Sort Question?

  • Thread starter Thread starter C#Schroeder
  • Start date Start date
C

C#Schroeder

I am new to SQL and am trying to sort some information. The data is
being sorted, but not in the way I desire it to be.

Example: Sorted Table Desired Sort
Product Name Product
Name
------------------------------
-------------------------
Test-1
Test-1
Test-10
Test-2
Test-11
Test-3
Test-12
Test-4
Test-2
Test-10
Test-3
Test-11
Test-4
Test-12

Thanks for any help.
 
I am new to SQL and am trying to sort some information.  The data is
being sorted, but not in the way I desire it to be.

Example:  Sorted Table                                   Desired Sort
     Product Name                                           Product
Name
------------------------------
-------------------------
    Test-1
Test-1
    Test-10
Test-2
    Test-11
Test-3
    Test-12
Test-4
    Test-2
Test-10
    Test-3
Test-11
    Test-4
Test-12

Thanks for any help.

Sorry Wrong forum. I thought I was in the SQL forum.
 
Anthony,

Well, to answer your question, you are going to have to sort it based on
the numeric value after "Test-".

If you know that the first five characters are always going to be
"Test-", then you can use this order by statement:

order by convert(int, right(<field>, len(<field>) - len("Test-")))


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I am new to SQL and am trying to sort some information. The data is
being sorted, but not in the way I desire it to be.

Example: Sorted Table Desired Sort
Product Name Product
Name
------------------------------
-------------------------
Test-1
Test-1
Test-10
Test-2
Test-11
Test-3
Test-12
Test-4
Test-2
Test-10
Test-3
Test-11
Test-4
Test-12

Thanks for any help.

Sorry Wrong forum. I thought I was in the SQL forum.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top