How to create a sort number in CL or query?

15 pts.
Tags:
AS/400
AS/400 Query
CL Program
Hi all, I already create a PF with a field name "NUMBER". I want to fill this Field "NUMBER" with a sort number like 1 2 3 4 5 6 7 Etc . Can anyone help me how to create CL programming to fill the NUMBER field with sort number like 1 2 3 4 Etc . It's almost creating a sort number in Excel . Please advise.

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • ToddN2000
    What does your PF look like? I am guessing you have multiple fields in the record and a field called number you want to sort on. How do you determine what the "NUMBER" value is going to be ? This sounds like it would be easier to do using SQL and the analytic function RANK. Something like this.

    select ord#,item,part RANK() OVER(PARTITION BY part ORDER BY part,ord# DESC,item) AS rank_id from orderdetail 
    11,025 pointsBadges:
    report
  • indiesrm1973
    PF from DSPTAP to OUTFILE. Then i selected the record with substr . I want to add new field " number " with a value 1 2 3 4 5 etc. I don't know how to create a new field " number " with a value 1 2 3 . Can query or CL handle what i want ? please advise .
    15 pointsBadges:
    report
  • ToddN2000
    You can add a column to a table using SQL
    Then you fill in your new column with your sort/rank number.

    Add a column by running the SQL command
    ALTER TABLE table ADD COLUMN colname





    11,025 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following