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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:16:09+00:00 2026-05-18T11:16:09+00:00

This works fine: SELECT c.id, c.name, c.ascii_name, COUNT(*) AS nr FROM cities c INNER

  • 0

This works fine:

SELECT c.id, c.name, c.ascii_name, COUNT(*) AS nr
    FROM cities c 
    INNER JOIN jobs j ON (j.city_id = c.id ) 
    WHERE j.is_active = 1 
    GROUP BY c.name
limit 100

but when I want to put the condition on th new column nr it says column not found

SELECT c.id, c.name, c.ascii_name, COUNT(*) AS nr
    FROM cities c 
    INNER JOIN jobs j ON (j.city_id = c.id ) 
    WHERE j.is_active = 1 and nr > 100
    GROUP BY c.name
LIMIT 100
  • 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-05-18T11:16:10+00:00Added an answer on May 18, 2026 at 11:16 am

    You should put the condition on nr in the HAVING clause, like this:

    SELECT c.id, c.name, c.ascii_name, COUNT(*) AS nr
        FROM cities c 
        INNER JOIN jobs j ON (j.city_id = c.id ) 
        WHERE j.is_active = 1
        GROUP BY c.name
        HAVING nr > 100
    limit 100
    

    This is because nr is the result of an aggregate function (COUNT(*)) and as such is not available at the time the WHERE filter is applied.

    EDIT: in some database servers, the reference to nr doesn’t work; you can also use HAVING COUNT(*) > 100.

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

Sidebar

Related Questions

so I have this code it works fine SELECT NAME, Country, NORMAL_STATE, CURRENT_STATE FROM
This query works fine for me: $query = SELECT p.topnode_id, p.param_key, p.param_value FROM tbl_params
In SQL SERVER 2005 This query works fine : Select * from sys.procedures where
So I got this statement, which works fine: SELECT MAX(patient_history_date_bio) AS med_date, medication_name FROM
I'm using this statement in SQLServer and it works fine: SELECT TOP 1000 *
I have this jQuery script that works fine: $(select).change(function () { var finalPrice =
I have the following select statement which works fine SELECT status_id, COUNT(status_id) As total
Ex: select distinct new JPQA.QueryResultObjectV1(space.name,spaceID) + from Space space,Building building,Floor floor join space.guid.oid spaceID
This works fine: $.getJSON(http://localhost:59396/xxxWeb/ CarouselHandler.ashx?action=getproducts&ids= + ids, function(data) { carousel.size(allProductIDs.length); if (numberOfImagesLeftToShow < numberOfImagesToDisplay)
This works fine: GET /mvc/Movies/TitleIncludes/Lara%20Croft When I submit a request that contains a colon,

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.