Page 1 of 1

Sequence number

Posted: Mon Dec 15, 2008 2:25 am
by veera24
hi all,
I'm in need to generate sequential number based on the follwing criteria.

If my record starts with '6' then i got to generate the number starting from '01' and If the record starts with some other number then it should be one.
Here the main criteria is the records starting with '6' wont be in order. I mean the records with other than '6' will also be in middle.At that time the sequence number should be genrated from the previous value being generated.

For example.
Input --> Sequence number

623 then 01
640 then 02
590 then 01
875 then 01
634 then 03
627 then 04


Could any one suggest me how to generate the same.

Your time will highly appreciated.

Thanks in advance,
Veera

Posted: Mon Dec 15, 2008 6:19 am
by balajisr
Have two stage variable namely svInd and svCnt.

Derivation for svInd

Code: Select all

If InRec.Col1[1,1]=6 then @TRUE else @FALSE
I had assumed that the input is a string.

Derivation for svCnt

Code: Select all

If svInd then svCnt + 1 else svCnt
In your output column derivation have the following code:

Code: Select all

If svInd then svCnt else 1
You need not sort data.

Posted: Mon Dec 15, 2008 7:49 am
by chulett
:!: Nit pick alert!

You do not need to specifically set an expression to "true" or "false", that is automatic when it is evaluated. So rather than the derivation posted for svInd, it can simply be:

Code: Select all

InRec.Col1[1,1]=6
FYI.

Posted: Mon Dec 15, 2008 3:01 pm
by ray.wurlod
Use the Fmt() function to add leading zeroes. Beware, however, that this will give "strange" results if your count goes over the number of digits you specify in your format string.

Posted: Mon Dec 15, 2008 10:54 pm
by balajisr
Thanks Craig for your useful alert. :)

Posted: Thu Dec 18, 2008 12:50 am
by veera24
balajisr wrote:Thanks Craig for your useful alert. :)
As i don't have the membership i couldn't see chulett's comment. So could you pls. help me out to get to know. :( :(

Thanks in advance,
Veera

Posted: Thu Dec 18, 2008 12:56 am
by balajisr
veera24 wrote:
balajisr wrote:Thanks Craig for your useful alert. :)
As i don't have the membership i couldn't see chulett's comment. So could you pls. help me out to get to know. :( :(

Thanks in advance,
Veera
I am sorry.It is not fair to post premium content.

Why don't you buy premium membership. Certainly worth it.

Posted: Thu Dec 18, 2008 11:54 pm
by veera24
balajisr wrote:
veera24 wrote:
balajisr wrote:Thanks Craig for your useful alert. :)
As i don't have the membership i couldn't see chulett's comment. So could you pls. help me out to get to know. :( :(

Thanks in advance,
Veera
I am sorry.It is not fair to post premium content.

Why don't you buy premium membership. Certainly worth it.
Hi,
Its ok at the least you can guide me right?instead posting Chulett's comments.

Thanks,
veera

Posted: Fri Dec 19, 2008 12:04 am
by chulett
Balajisr has already guided you. Nothing I added fundamentally changed what he said.

Posted: Mon Dec 22, 2008 9:25 pm
by veera24
chulett wrote:Balajisr has already guided you. Nothing I added fundamentally changed what he said. ...
Yeah thanks chulett.