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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:57:15+00:00 2026-05-13T10:57:15+00:00

I was wondering why can’t I use alias in a count(*) and reference it

  • 0

I was wondering why can’t I use alias in a count(*) and reference it in the having clause. For instance:

select Store_id as StoreId, count(*) as _count
    from StoreProduct
    group by Store_id
        having _count > 0

Wouldn’t work.. But it works if I remove _count and use count(*) instead.

  • 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-13T10:57:16+00:00Added an answer on May 13, 2026 at 10:57 am

    See the document referenced by CodeByMoonlight in an answer to your recent question.

    The HAVING clause is evaluated before the SELECT – so the server doesn’t yet know about that alias.

    1. First the product of all tables in the from clause is formed.
    2. The where clause is then evaluated to eliminate rows that do not satisfy
      the search_condition.
    3. Next, the rows are grouped using the columns in the group by clause.
    4. Then, Groups that do not satisfy the search_condition in the having
      clause
      are eliminated.
    5. Next, the expressions in the select clause target list are
      evaluated.
    6. If the distinct keyword in present in the select clause, duplicate rows
      are now eliminated.
    7. The union is taken after each sub-select is evaluated.
    8. Finally, the resulting rows are sorted according to the columns
      specified in the order by clause.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering how can I programmatically copy all the discussion items from one
I am wondering how can one delete an entity having just its ID and
I'm wondering how can I use Lucene for searching and indexing with PHP, Google
After hearing about OSGi fragments, I was wondering: Can I use a fragment to
I am wondering can I do a where clause that takes in a collection?
I'm wondering how can I reference another project in Eclipse Java EE projects, just
I'm wondering can I use static libraries (lib*.a files) compiled with one version of
Strange question, but someone showed me this, I was wondering can you use the
I was wondering how can I set a timeout on a socket_read call? The
I'm wondering how can I submit a form via Ajax (using prototype framework) and

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.