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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:54:20+00:00 2026-05-31T03:54:20+00:00

i have a table with 3 columns. It is having duplicate on column 2

  • 0

i have a table with 3 columns. It is having duplicate on column 2 and 3. I need to select pnly the duplicate rows (with all the 3 columns). How to do that? pls help me.

var1 var2 var3

a a a
b a a
c a a
d b b
e c c

The above is the table structure. It has 3 columsn var1, var2, var3. Based on column var2 and var3 only, we have to assume it is duplicate records. We should not consider var1 while finding the duplicate. Sorry about the alignment.

I have used the below query to get all the rows with / without duplicate but with the rank to identify the duplicate records. But i could not get only the duplicate records.

select var1,var2,var3,ROW_NUMBER() over(PARTITION BY
var2,var3 order by var2,var3) as rnk
from vart

Apart from this, how i can get the maximum rank records amoung the duplicate entries ?
Thanks.

  • 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-05-31T03:54:22+00:00Added an answer on May 31, 2026 at 3:54 am

    If you want all the rows that have duplicates you can use count(*) over()

    select var1, var2, var3
    from (
          select var1,
                 var2,
                 var3,
                 count(*) over(partition by var2, var3) as dc
          from YourTable
         ) as T
    where dc > 1
    

    Result:

    var1 var2 var3
    ---- ---- ----
    a    a    a
    b    a    a
    c    a    a
    

    If you want all duplicates but one use row_number() over() instead.

    select var1, var2, var3
    from (
          select var1,
                 var2,
                 var3,
                 row_number() over(partition by var2, var3 order by var1) as rn
          from YourTable
         ) as T
    where rn > 1
    

    Result:

    var1 var2 var3
    ---- ---- ----
    b    a    a
    c    a    a
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: SELECT <column>, count(*) FROM <table> GROUP BY <column> HAVING
I have a table having 2 columns EmployeeId (int) and EmployeeDetails(XMl type) EmployeeId EmployeeDetails
I have a table named with Sales having the following columns: Sales_ID|Product_Code|Zone|District|State|Distributor|Total_Sales Now i
I have the following query: select column_name, count(column_name) from table group by column_name having
Having a table with a column like: mydate DATETIME ... I have a query
I have table with 3 columns A B C. I want to select *
I have a table with columns ID, DateStamp and the ID need not be
Possible Duplicate: Datetime vs Timestamp? I have a Mysql table, which has a column
I have a problem of listing duplicated rows that include NULL columns. Lemme show
I have an MSSQL 2000 table that has a lot of duplicate entries. Each

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.