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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:10:28+00:00 2026-06-13T13:10:28+00:00

SELECT count(*), lower(name), number FROM tbl GROUP BY lower(name), number HAVING count(*) > 1;

  • 0
SELECT count(*), lower(name), number
FROM   tbl
GROUP  BY lower(name), number
HAVING count(*) > 1;

input tb1

slno name number
1    aaa   111
2    Aaa   111
3    abb   221
4    Abb   121
5    cca   131
6    cca   141
7    abc   222
8    cse   222

This query can just find the duplicates in the number and names which are same but it wont be able find the duplicates in the 3 and 4th row!!!

 SELECT count(*), lower(name)
    FROM   tbl
    GROUP  BY lower(name)
    HAVING count(lower(name)) > 1

this query can find all the duplicates in name!!! it works perfectly

 SELECT count(*), number
    FROM   tbl
    GROUP  BY number
    HAVING count(number) > 1

this query can find all the duplicates in number!!! it works perfectly

I want a query which can find all the duplicates in both name and number whether the name consists of lower case and upper case

output
name number count
2    111     aaa
2    ---     abb
2    ---     cca
2    222     ---
  • 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-13T13:10:29+00:00Added an answer on June 13, 2026 at 1:10 pm

    Updated question

    "Get duplicate on both number and name" … "name and number as different column"
    Rows can be counted twice here!

    SELECT lower(name), NULL AS number, count(*) AS ct
    FROM   tbl
    GROUP  BY lower(name)
    HAVING count(*) > 1
    
    UNION  ALL
    SELECT NULL, number, count(*) AS ct
    FROM   tbl
    GROUP  BY number
    HAVING count(*) > 1;
    

    -> sqlfiddle

    Original question

    The problem is that the query groups by

    GROUP  BY lower(name), number
    

    As row 3 and 4 have a different number, they are not the same for this query.

    If you want to ignore different numbers for this query, try something like:

    SELECT lower(name)
         , count(*) AS ct
    FROM   tbl
    GROUP  BY lower(name)
    HAVING count(*) > 1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Query SELECT COUNT(*), name, number FROM tbl GROUP BY name, number HAVING COUNT(*) >
select count(*) as count from table group by foreign_id order by count This returns
SELECT COUNT(*) FROM BigTable_1 Which way I should to use to get number of
SELECT count(*) FROM table WHERE column ilike '%/%'; gives me the number of values
SELECT COUNT(`t`.id) FROM `product` `t` INNER JOIN `category` `c1` ON ( `c1`.id ='15' )
SELECT * FROM( (SELECT count(DISTINCT RECEPIENT_ID) as NoOfUsers, TO_CHAR(ACTN_TAKE_DATA_TM,'YYYY-MM-DD') as accDate FROM ALRT_PLATFORM_ALRT_HSTRY where
TOPIC_COUNT_SQL = SELECT COUNT(*) FROM topics_topic WHERE topics_topic.object_id = maps_map.id AND topics_topic.content_type_id = %s
SQL : SELECT COUNT(usr.id) as `total_results` FROM users as usr LEFT JOIN profile as
Example: select count(*) from my table where column1 is not null and (column1 =
I want to do SELECT count(*) FROM users where created_at within 3 days ago

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.