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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:52:20+00:00 2026-05-11T02:52:20+00:00

I have a query like this: SELECT t1.id, (SELECT COUNT(t2.id) FROM t2 WHERE t2.id

  • 0

I have a query like this:

SELECT t1.id,     (SELECT COUNT(t2.id)      FROM t2      WHERE t2.id = t1.id           ) as num_things FROM t1 WHERE num_things = 5; 

The goal is to get the id of all the elements that appear 5 times in the other table. However, I get this error:

ERROR: column 'num_things' does not exist SQL state: 42703 

I’m probably doing something silly here, as I’m somewhat new to databases. Is there a way to fix this query so I can access num_things? Or, if not, is there any other way of achieving this result?

  • 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. 2026-05-11T02:52:21+00:00Added an answer on May 11, 2026 at 2:52 am

    I think you could just rewrite your query like so:

    SELECT t1.id FROM t1 WHERE (SELECT COUNT(t2.id)      FROM t2      WHERE t2.id = t1.id           ) = 5; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query which goes like this :- SELECT count(*) as count FROM
I have a query like this: select author1 from books_group where category='cse' union select
I have a SQL statement that is something like this SELECT t1.* CASE WHEN
SELECT p.PostPID, p.PostUID, p.PostText, p.PostTime, u.UserUID, u.UserName, u.UserImage, u.UserRep, ( SELECT COUNT(f.FlagTime) FROM Flags
Let's say I have this data in a MSSQL table type status a open
I'm pretty sure that I need to be doing left outer joins on my
I have a MySQL database containing a user's country and whether they are an
Not sure if this is possible, but if it is it would make my
I have a table with a field called type , where 3 various rows
To simplify, I have tree tables: products , products-vs-orders , orders products fields :

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.