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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:53:46+00:00 2026-05-14T03:53:46+00:00

If my table looks like this: CREATE TABLE `daily_individual_tracking` ( `daily_individual_tracking_id` int(10) unsigned NOT

  • 0

If my table looks like this:

CREATE TABLE `daily_individual_tracking` (
  `daily_individual_tracking_id` int(10) unsigned NOT NULL auto_increment,
  `daily_individual_tracking_date` date NOT NULL default ''0000-00-00'',
  `sales` enum(''no'',''yes'') NOT NULL COMMENT ''no'',
  `repairs` enum(''no'',''yes'') NOT NULL COMMENT ''no'',
  `shipping` enum(''no'',''yes'') NOT NULL COMMENT ''no'',
  PRIMARY KEY  (`daily_individual_tracking_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1

basically the fields can be either yes or no.

How can I count how many yes’s their are for each column over a date range?

Thanks!!

  • 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-14T03:53:46+00:00Added an answer on May 14, 2026 at 3:53 am

    You can either run three queries like this:

    SELECT COUNT(*)
    FROM daily_individual_tracking
    WHERE sales = 'YES'
    AND daily_individual_tracking_date BETWEEN '2010-01-01' AND '2010-03-31' 
    

    Or if you want you can get all three at once like this:

    SELECT (
        SELECT COUNT(*)
        FROM daily_individual_tracking
        WHERE sales = 'YES'
        AND daily_individual_tracking_date BETWEEN '2010-01-01' AND '2010-03-31'
    ) AS sales_count, (
        SELECT COUNT(*)
        FROM daily_individual_tracking
        WHERE repairs = 'YES'
        AND daily_individual_tracking_date BETWEEN '2010-01-01' AND '2010-03-31'
    ) AS repairs_count, (
        SELECT COUNT(*)
        FROM daily_individual_tracking
        WHERE shipping = 'YES'
        AND daily_individual_tracking_date BETWEEN '2010-01-01' AND '2010-03-31'
    ) AS shipping_count
    

    Another way to do it is to use SUM instead of COUNT. You could try this too to see how it affects the performance:

    SELECT
        SUM(sales = 'YES') AS sales_count,
        SUM(repairs = 'YES') AS repairs_count,
        SUM(shipping = 'YES') AS shipping_count
    FROM daily_individual_tracking
    WHERE daily_individual_tracking_date BETWEEN '2010-01-01' AND '2010-03-31'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The table looks like this: CREATE TABLE `tweet_tweet` ( `id` int(11) NOT NULL AUTO_INCREMENT,
I've got a table that looks like this: CREATE TABLE CustomerXmlData (CustomerId int, CustomerData
I'd like to create a table that looks like this: lolvalue---------|lol date|some other column
My SQL table looks like this: CREATE TABLE Page ( Id int primary key,
Imagine a table that looks like this: CREATE TABLE [dbo].[test]( [id] [uniqueidentifier] NULL, [name]
I have a database table that looks like this: CREATE TABLE IF NOT EXISTS
I have a table that looks like this: CREATE TABLE [Test].[dbo].[MyTest] ( [Id] INT
I have a table that looks like this CREATE TABLE IF NOT EXISTS `language`
my table looks like this: create table foos( id uniqueidentifier primary KEY DEFAULT (newsequentialid()),
I have this table that looks like this CREATE TABLE `purchases` ( `id` INT(10)

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.