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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:38:14+00:00 2026-06-01T18:38:14+00:00

I have following problem: I want to count data in one table, count data

  • 0

I have following problem:
I want to count data in one table, count data in second table and compare countings in having clause, and display only that rows which have the same countings
Something like that:

SELECT bla
FROM T1 t1 JOIN T2 t2
ON t1.id = t2.id
HAVING COUNT(counted data from table1) = COUNT(counted data from table2)

Do you have any idea?
Cheers

  • 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-01T18:38:15+00:00Added an answer on June 1, 2026 at 6:38 pm

    Standard SQL:

    SELECT t1.bla, t1.id, t1.counter, t2.counter
      FROM (SELECT t1.bla, t1.id, COUNT(counted_data_from_t1) AS counter
              FROM t1
             GROUP BY t1.bla, t1.id
           ) AS t1
      JOIN (SELECT t2.id, COUNT(counted_data_from_t2) AS counter
              FROM t2
             GROUP BY t2.id
           ) AS t2
        ON t1.id = t2.id AND t1.counter = t2.counter
    

    Oracle SQL (because Oracle doesn’t like AS before table aliases):

    SELECT t1.bla, t1.id, t1.counter, t2.counter
      FROM (SELECT t1.bla, t1.id, COUNT(counted_data_from_t1) AS counter
              FROM t1
             GROUP BY t1.bla, t1.id
           ) t1
      JOIN (SELECT t2.id, COUNT(counted_data_from_t2) AS counter
              FROM t2
             GROUP BY t2.id
           ) t2
        ON t1.id = t2.id AND t1.counter = t2.counter
    

    You just have to decide where bla comes from; I nominated t1. I’m assuming that for any given value of t1.id, there is a single value of t1.bla. If there isn’t, then you need to explain much more clearly what you’re counting and where the various columns are, and what the keys of the tables are.

    Update: Apologies for not noticing the Oracle tag and giving invalid Oracle syntax.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem: Within a stylesheet document I want to create an
I have the following problem. I want to check that the item clicked on
Hi I have the following problem, I want to laod a website with php.
What kind of strategy do I have for the following problem. I want to
I have the following code I want to run, but the problem is $this->type
I have the following code: The actual problem is the non-quoted code. I want
A] Problem Summary: I have one to many data models in my project. I
I have the following table: OrderHasItem OrderTable_idOrder Item_idItem quantity SELECT Item_idItem, COUNT(Item_idItem)+quantity FROM OrderHasItem
Let's say I have the following hypothetical data structure: create table country ( country_id
I have following problem: I have built a tabbar application with 4 tabs. I

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.