Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8062181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:34:56+00:00 2026-06-05T10:34:56+00:00

I have table consisting of notes for every user which looks like this: user_id

  • 0

I have table consisting of notes for every user which looks like this:

user_id    note_id
-------    -------
      1       1232
      1       1246
      1       1223
      2       3342
      2       2134
      3       3212
      3       1243
    ...        ...

And now i like to implement an ordering mechanism which would allow user to arrange these notes in a user-specified way so that the final table would look something like this:

user_id    note_id  note_order
-------    -------  ----------
      1       1232          1
      1       1246          2
      1       1223          3
      2       3342          1
      2       2134          2
      3       3212          1
      3       1243          2
    ...        ...        ...

Of course after adding this column it has NULL values and I’m not allowed to create any more sequences in the database. Is there any way in ORACLE to achieve this goal?

I’d like the values in order column to start from 1 to the number of notes for every user and preferably do this in one update statement. If it`s impossible this way what would be the best construction for an PL/SQL loop or is there any other effective way to do this?

Looking forward to any possible help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:34:57+00:00Added an answer on June 5, 2026 at 10:34 am

    You don’t need to store this value, you can simply generate this during retrieval.

    select user_id,
           note_id,
           row_number() over (partition by user_id order by note_id)
    from your_table
    

    If you really need to update the table, you could do something like this:

    merge into your_table ut
    using (
      select rowid, 
             row_number() over (partition by user_id order by note_id) as rn
      from your_table
    ) t on (ut.rowid = t.rowid)
    when matched then update
      set order_column = rn;
    

    Note that you cannot create a column order because that is a reserved word (well actually you can by using double quotes, but I would strongly recommend not doing that).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this great function that parses a field into a pivot table consisting
This is the question I have. Develop a salary sheet from emp table consisting
I have a database table consisting of countries. In my DAO which extends HibernateDAOSupport
I have this setup: an output table where my results will end up consisting
I have a table of users which has a username column consisting of a
I have table consisting of these fields: id | date_from | date_to | price
I have table consisting of these fields: id | date_from | date_to | price
I have a (simplified) table consisting of three columns: id INT PRIMARY KEY NOT
I have a large table consisting of over 60 millions records and I would
I have an HTML Table consisting of several rows. I am trying to insert

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.