select count

arkiboys 9,686 Reputation points
2022-11-28T07:55:44.137+00:00

hello
I can find out if column1 has a count > 1
example, select column1, count() from tblMain group by column1 having count() > 1
question, how can I check if two columns have more than one repeated values?
perhaps something like:
select column1, column2, count() group by column1, column2 having count() > 1 but this does not work
any suggestions please?
thank you

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,597 questions
0 comments No comments
{count} votes

Accepted answer
  1. LiHongMSFT-4306 25,651 Reputation points
    2022-11-28T08:29:57.607+00:00

    Hi @arkiboys

    how can I check if two columns have more than one repeated values?

    Normally, this query will work: select column1, column2, count(*) from tblMain group by column1, column2 having count(*) > 1

    The reason might be that you lost 'from tblMain' in your code.

    Best regards,
    LiHong


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful