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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:18:55+00:00 2026-05-14T23:18:55+00:00

I have a view with some joins in it. I’m doing a select from

  • 0

I have a view with some joins in it. I’m doing a select from that view with COUNT(*) as one of the columns of the select. I’m surprised by the number it’s returning. Note that there is no GROUP BY nor aggregate column statement in the source view that the query is drawing from.

How can I take it apart to see how it arrives at this number? I have three columns in the GROUP BY clause.

SELECT column1, column2, column3, COUNT(*) FROM View GROUP BY column1, column2, column3

I get a result like

+---------+---------+---------+----------+
| column1 | column2 | column3 | COUNT(*) |
+---------+---------+---------+----------+
| value1  | valueA  | value_a |      103 |
+---------+---------+---------+----------+
| value2  | valueB  | value_b |       56 |
+---------+---------+---------+----------+
etc.

I’d like to see how it arrives at that 103, 26, etc. In other words, I want to run a query that returns 103 rows of something, so that I know that I’ve expressed the query properly. I’m double-checking my work.

I’m not saying that I think COUNT(*) doesn’t work ( I know that “SELECT is not broken” ), what I want to double-check is exactly what I’m expressing in my query, because I think I’ve expressed the wrong thing, which would be why I’m getting unexpected values. I need to see more what I’m actually directing MySQL to count.

So should I take them one by one, and try out each value in a WHERE clause? In other words, should I do

SELECT column1 FROM View WHERE column1 = 'first_grouped_value'
SELECT column1 FROM View WHERE column1 = 'second_grouped_value'
SELECT column2 FROM View WHERE column1 = 'first_grouped_value'
SELECT column2 FROM View WHERE column1 = 'second_grouped_value'

and see the row count returned matches the COUNT(*) value in the grouped results?

Because of confidentiality, I won’t be able to post any of the query or database structure. All I’m asking for is a general technique to see what COUNT(*) is actually counting.

  • 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-14T23:18:56+00:00Added an answer on May 14, 2026 at 11:18 pm

    What has surprised you about the number? What did you expect? What did you actually need to calculate?

    Your count will be the number of rows in the full grouping. Image if you want to count hours but grouped by year, month and day. Your count will 24 as this is the number of hours for each day within each month within each year.

    Any of these variations should help see the grouping;

    SELECT column1, count(*)
    FROM view
    GROUP BY column1    
    
    SELECT column2, count(*)
    FROM view
    GROUP BY column2    
    
    SELECT column3, count(*)
    FROM view
    GROUP BY column3    
    
    SELECT column1, column2, count(*)
    FROM view
    GROUP BY column1, column2
    
    SELECT column2, column3, count(*)
    FROM view
    GROUP BY column2, column3
    
    SELECT column1, column3, count(*)
    FROM view
    GROUP BY column1, column3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario: I have a view that has some DataTemplate resources <DataTemplate x:Key=myDragCueTemplate> <Border Background=Blue
I have one specific view created in my DB(joins about 5-6 tables with a
I have a view that uses 11 outer joins and two inner joins to
I have a view that loops over a database table returning dogs information. Here's
I have a View where some input text to be added dynamica using jquery,
In my xib file I have some View. And I have PainView class (UIView).
I have a View controller displaying some information (not table views). I have an
I have an scroll view with some sophisticated animations happening during scrolling. Although after
I have a table view with some words, and i present flash-card style landscape
I have my own view with some values. How i can call on click

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.