Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Order data by middle string Post Reply Post New Topic
Author Message
SkinnerY2K
Newbie
Newbie


Joined: 24 Mar 2010
Location: United Kingdom
Online Status: Offline
Posts: 1
Quote SkinnerY2K Replybullet Topic: Order data by middle string
     Posted: 24 Mar 2010 at 11:37pm
I am trying to write a report which will order my data by the middle part of the string

eg string 'AB09WER' I need to order it by th '09' part.

Can this be done? I have Crystal 2008

thanks
IP IP Logged
Yudi
Newbie
Newbie


Joined: 03 Aug 2009
Online Status: Offline
Posts: 13
Quote Yudi Replybullet Posted: 25 Mar 2010 at 2:15am
I think you just need to write a simple stored proc like the following :
 
select <field>
from <table>
order by mid(StringField,3,2) asc;
 
and then make the above SP as the datasource for your report
Thanks And Regards
Yudi Purwanto
http://yudio.net/
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 25 Mar 2010 at 6:22am
If you created a group using that formula, that should work also.  You may want to hide the group header and group footer.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 Mar 2010 at 8:10am
The stored procedure is likley more efficient but if you are limited to using a crystal solution (no sp options) and always are using the 3rd and 4th characters in the field to sort on, you can create a crystal formula field as:
mid({table.field},3,2)
and sort on this formula field in the crystal sort expert.
Same idea as Yudi but no stored proc is needed.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum