[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: Sorting in SQR
Hi Frank:
Here is an example.
move &A.GL_Expense to $GL_Expense
Extract $Firstfour from $GL_Expense 0 4 !start position, length
Extract $Lastseven from $GL_Expense 5 7 ! id
display $Firstfour
display $Lastseven
Hope this helps.
Aya
Frank Severinsson wrote:
>
> I have a problem with sorting in SQR/SQL.
>
> I this sounds crazy but I have a client that have a GLACCOUNT-string with
> different lengths and different number of segments
> and they want to sort their transactions on segment 3 (if there is one).
> So, I wonder, is it possible to sort on a part of a column and the only
> thing I know about the part, is that it begins after the second '-'.
> Example:
>
> The GLACCOUNT-strings could look like this:
>
> B-1234-43546-12
> B-1245
> C
> C-343-5678
> C-768-767898-34545
> B
> B-4345
> B-6567-30
> C-5456-30
>
> And I want the result to be like this:
>
> B
> B-1245
> B-4345
> C
> B-5456-30
> B-6567-30
> B-1234-43546-12
> B-343-5678
> B-768-767898-34545
>
> I have tried the SQL-functions SUBSTR(), INST(), LPAD(), RPAD(), LTRIM(),
> RTRIM() in all kind of ways but without success.....
>
> Does anyone have any idea ?
>
> Frank Severinsson
> PSDI Norden