Jump to content

Sorting varchar data numerically


yashshah

Recommended Posts

Hey guys i have this problem here,

I have some data which goes like

1900

1899

1898

 

100

C-1

C-21

C-100

A-200

A-100

etc..

 

These are basically item codes which needs to be sorted numerically. This column rite now is of varchar type.

The data what i am looking for is something like

 

1900

1899

1898

A-200

A-100

C-100

C-21

C-1

 

This is killing my project here and my dean wont accept the project without this..Need help badly.

Thanks in advance

Link to comment
Share on other sites

Well not really.. I need them sorted according to the item codes.

The codes go as.

 

2000 to say 100.

A few have C-200 to C-01

A few are U-200 to U-01

Others would be BU-200 to U-01.

 

What is desirable is that the numbers get sorted desc first. Followed with an alphabet sorting along with a numerical sort approach.

 

Let me know if you dont understand what im saying here.

Link to comment
Share on other sites

Yup ur rite.. these are item codes. A few of them are numerical and a few are prefixed by Alphabets followed by a hyphen and a numerical value i.e A-1 or B-1..

The criteria is to get the numerical ones first and then the ones which prefixes an alphabet.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.