Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort Order Crystal Reports

Status
Not open for further replies.

Christine19

Programmer
Sep 25, 2012
1
PH
Hi,

I am in trouble Sorting a field in crystal reports.

This is my output sorted data:

2012-C1-6
2012-C2-7
2012-C3-8
2012-C4-9
2012-C5-10
2012-C1-1
2012-C2-2
2012-C3-3
2012-C4-4
2012-C5-5


I sort this by setting Record Sort Expert and i set it by Ascending order in Crystal Reports

Is there another way to sort it like this:

2012-C1-1
2012-C2-2
2012-C3-3
2012-C4-4
2012-C5-5
2012-C1-6
2012-C2-7
2012-C3-8
2012-C4-9
2012-C5-10


I tried searching it on google but no luck finding near idea or answer in my problem.

Pls help. Thanks in advance.
 
Assuming the first 8 characters are always of the form "YYY-CN-" then you are going to have to break the column into two pieces for sorting.
Code:
order by left(column1,8), cast(substring(9,2) as int)
Adjust the "9,2" as needed for longer entries in the column. If the first 8 characters are not always in the same format, then the sorting will be much more difficult. Also, this may not work if the last two characters aren't always numbers.

Auguy
Sylvania/Toledo Ohio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top