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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:10:57+00:00 2026-06-17T14:10:57+00:00

I haven’t had to work with SQL queries in quite a while and what

  • 0

I haven’t had to work with SQL queries in quite a while and what seems like a simple query is driving me insane. I have a table of transactions from which I am trying to select repetition based on various criteria. The relevant table structure is as follows:

[Transaction]
* ID          int
  Transacted  datetime
  Name        nvarchar(50)
  Description nvarchar(4000)
  size        bigint

From this table, I need to find duplicates of the name / size and report back all records where the name had the same size transaction, even if date and description differ. I can get counts with just the name with the following:

SELECT   Name, COUNT(Name) AS Count
FROM     Transaction
GROUP BY Name

And then I could do an inner join on that to get the rest of the data:

SELECT data.ID, data.Transacted, data.Name, data.Description, data.Size, counts.Count
FROM (SELECT  Name, COUNT(Name) AS Count
      FROM  Transaction
      GROUP BY Name) AS counts 
INNER JOIN Transaction AS data ON counts.Name = data.Name
WHERE     (counts.Count > 1)
ORDER BY  data.Name, data.Transacted

But obviously this is only giving me transactions where the name is repeated — not where both the name and size are repeated.

I’m looking for help finishing this piece off so that I report all of the data where the lines show a repeat of the same name and same size. I could easily concatinate the data from both columns into one result and compare against that, but I’m not sure that’s the optimal appropach.

Thanks in advance.

  • 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-17T14:10:59+00:00Added an answer on June 17, 2026 at 2:10 pm

    The code in the question indicates that you also need additional columns. To return all rows with duplicated Name, size you can use

    WITH CTE
         AS (SELECT *,
                    COUNT(*) OVER (PARTITION BY Name, size) AS Cnt
             FROM   [Transaction])
    SELECT ID,
           Transacted,
           Name,
           Description,
           size
    FROM   CTE
    WHERE  Cnt > 1 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I haven't had a lot of exposure to CSS media queries; I'm basically learning
Haven't found in docs. Does java ResultSet supports query arguments,like jdbcTemplate? For example, something
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Haven't seen anything about it here but it seems to solve one of the
I haven't designed a website for about 3 years now, so I am quite
I have just tried to save a simple *.rtf file with some websites and
Haven't done as much of Javascript as I should have done. I am trying
Haven't seen anything, but I have seen that you can create albums in the
haven't used regex replaces much and am not sure if how I have done
Haven't seen this before so hopefully someone has a easy solve, I have a

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.