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 7759167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:33:32+00:00 2026-06-01T13:33:32+00:00

My table and data as following, declare @t1 table (myID varchar(200), chequeNo varchar(20)); insert

  • 0

My table and data as following,

declare @t1 table (myID varchar(200), chequeNo varchar(20));
insert into @t1 values('2011-01-03809','1925');
insert into @t1 values('2011-01-03810','1989');
insert into @t1 values('2011-01-03791','BIMB 256247');
insert into @t1 values('2011-01-03789','BIMB 256247');
insert into @t1 values('2011-01-03792','BIMB 256247');
insert into @t1 values('2011-01-03793','BIMB 256247');
insert into @t1 values('2011-13-00430','mbb 385030');
insert into @t1 values('2011-13-00431','mbb 385030');
insert into @t1 values('2011-01-03645','bmmb 003095');
insert into @t1 values('2011-08-00608','CIMB 376443');
insert into @t1 values('2011-08-00609','CIMB 385371');
insert into @t1 values('2011-04-00652','CIMB 512393');
insert into @t1 values('2011-13-00399','EBB 000639');
/* myID is a unique */

I would like to distinguish the chequeNo using update statment.

My expected result as following,

myID          | chequeNo
-----------------------------------
2011-01-03645   bmmb 003095
2011-01-03789   BIMB 256247 (1)
2011-01-03791   BIMB 256247 (2)
2011-01-03792   BIMB 256247 (3)
2011-01-03793   BIMB 256247 (4)
2011-01-03809   1925
2011-01-03810   1989
2011-04-00652   CIMB 512393
2011-08-00608   CIMB 376443
2011-08-00609   CIMB 385371
2011-13-00399   EBB 000639
2011-13-00430   mbb 385030 (1)
2011-13-00431   mbb 385030 (2)

Based on @t1 table, some chequeNo are the same although different myID. Relationship on myID to chequeNo looks like 1 to many. I want to make 1 to 1 (1 myID have a 1 chequeNo). So, I need to using update statement.

How my update statement looks like?

  • 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-01T13:33:33+00:00Added an answer on June 1, 2026 at 1:33 pm

    Rows can be renumbered using a ranking function.

    UPDATE subquery
    SET chequeNo = chequeNo + ' (' + CAST(sequence AS varchar(20)) + ')'
    FROM
    (
        SELECT *
        , sequence = ROW_NUMBER() OVER (PARTITION BY chequeNo ORDER BY myID)
        , reverseSequence = ROW_NUMBER() OVER (PARTITION BY chequeNo ORDER BY myID DESC)
        FROM @t1
    ) subquery
    WHERE NOT (sequence = 1 AND reverseSequence = 1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've tables and data as following, declare @tApplyProgram table (myID varchar(50), programID varchar(10), stTR
Given the following data/schema: DECLARE @t1 TABLE ( Id int NOT NULL ) DECLARE
I am trying to convert following table data into nested array using PHP. I
Consider the following data source: declare @Test table (EmpId int, ProdId int, Sold int)
Please see/run the following script. DECLARE @Products Table ( PId int ) INSERT @Products
I have the following script that I want to insert into a table, but
Please use following sample data. declare @tbl table (id int, fid int, arrival datetime,
I'm trying to insert data into a table using a plpgsql function or stored
Suppose we have the following table data: ID parent stage submitted 1 1 1
Lets say i have a table with the following data Customer table: Name amount

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.