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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:50:20+00:00 2026-05-13T00:50:20+00:00

Not sure exactly how to explain this but Imaging you have a table with

  • 0

Not sure exactly how to explain this but Imaging you have a table with lots of boolean fields like this……

Table: Cars

Columns:

Automatic: boolean

Silver: boolean

American: boolean

Noisy: boolean

Smelly: boolean

fast: boolean

(silly fields and most of them wouldn’t be bools in reality but just an example)

What I need to do is produce a list of these fields with a number of search results next to each one, so if there were 100 silver cars in the database and 57 American cars the list might look a bit like this…

Automatic: (150)

Silver (100)

American (57)

Noisy (120)

Smelly (124)

fast (45)

So, it’s basically like a list of filters, if the user clicks “silver” they will narrow the search down to only show silver cars and they know they will get 100 results. The numbers next to all the other filters will then decrease because we’ve filtered out all cars that aren’t silver.

Counting the occurences of one field would be easy….

SELECT COUNT(*) FROM CARS WHERE Automatic = true;

… would give me the first row for example. But I don’t want to have to do one SQL statement for each filter as there could be over 30 of them. I’ve seen plenty of sites do this so it must be easier than I think it is.

Any help would really be appreciated 🙂

Jon

  • 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-13T00:50:20+00:00Added an answer on May 13, 2026 at 12:50 am

    Assuming the bit is 1/0 then you can SUM instead of COUNT:

    SELECT SUM(Automatic) as Automatic, SUM(Smelly) as Smelly, SUM(American) as Japanese FROM ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure exactly how to get this. What I have is something like
Not sure what exactly is going on here, but seems like in .NET 1.1
I'm not sure exactly how to explain this, so I'll just start with an
Sorry about the title, I'm not exactly sure how to explain this with a
Not sure exactly how to word this question ... so edits are welcomed! Anyway
I'm not exactly sure how to ask this question really, and I'm no where
Not sure how to ask a followup on SO, but this is in reference
I'm not sure how to categorize this question, so let me just explain what
I am not sure exactly how to ask this question as I am not
Coming from a desktop background I'm not sure exactly how to pass the exceptions

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.