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

  • Home
  • SEARCH
  • 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 8069759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:09:57+00:00 2026-06-05T13:09:57+00:00

I have this data AnsID QuesID AnsOrder ———————– 1 5 NULL 2 5 NULL

  • 0

I have this data

AnsID  QuesID  AnsOrder
-----------------------
1       5       NULL
2       5       NULL
3       5       NULL
4       5       NULL
5       5       NULL
6       3       NULL
7       3       NULL
8       3       NULL
9       3       NULL
10      3       NULL
11      4       NULL
12      4       NULL
13      4       NULL
14      4       NULL
15      4       NULL
16      7       NULL
17      9       NULL
18      9       NULL
19      9       NULL
20      9       NULL
21      8       NULL
22      8       NULL
23      8       NULL
24      8       NULL

Want to UPDATE it into this format

AnsID  QuesID  AnsOrder
-----------------------

1       5       1
2       5       2
3       5       3
4       5       4    
5       5       5
6       3       1
7       3       2
8       3       3
9       3       4
10      3       5
11      4       1
12      4       2
13      4       3
14      4       4
15      4       5
16      7       1
17      9       1
18      9       2
19      9       3
20      9       4
21      8       1
22      8       2
23      8       3
24      8       4

Basicaly I want to update AnsOrder column in ascending order according to QuesID column,
like this for more readability.

AnsID  QuesID  AnsOrder
-----------------------

1       5       1
2       5       2
3       5       3
4       5       4    
5       5       5

6       3       1
7       3       2
8       3       3
9       3       4
10      3       5

11      4       1
12      4       2
13      4       3
14      4       4
15      4       5

16      7       1

17      9       1
18      9       2
19      9       3
20      9       4

21      8       1
22      8       2
23      8       3
24      8       4
  • 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-05T13:10:00+00:00Added an answer on June 5, 2026 at 1:10 pm

    You might generate row_numbers by quesID and assign them to AnsOrder like this:

    ; with ord as (
      select *,
             row_number() over (partition by quesID
                                order by AnsID) rn
        from table1
    )
    update ord 
       set ansorder = rn
    

    I’ve ordered by AnsID for consistency.
    Check this @ Sql Fiddle.

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

Sidebar

Related Questions

I have this data from a xml file: <?xml version=1.0 encoding=utf-8 ?> <words> <id>...</id>
I have this data: /blabla/blabla (abs,def) /yxz I use this regex (.*)(?:\(([^$]*)\))?\n But it
I have this data: 1, 0., 0., 1500. . . 21, 0., 2000., 1500.
I have this data in a table, for instance, id name parent parent_id 1
Let say if I have this data my_data = [ 10 20 30 40;
I have this class: public MyClass { public void initialize(Collection<String> data) { this.data =
Say I have this table schema. ID AccNo Amount Say I have this data
I'm using PostgreSQL 9.1 and I have this data structure: A B ------- 1
Let's say i have this json data. How to transform the tags to a
I have this array Array ( [data] => Array ( [0] => Array (

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.