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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:29:56+00:00 2026-05-25T06:29:56+00:00

Usually I feel pretty confident with SQL queries, however this one has me scratching

  • 0

Usually I feel pretty confident with SQL queries, however this one has me scratching my head. I feel like this -should- be a quick fix, but I’m just not seeing it.

I’m trying to do a count on multiple values on the same table, in one query.

Don’t mind the “0000000000000000” it’s just representing an empty byte array.

Is there an easy way to combine these queries?

SELECT COUNT(ssn)
FROM patients
WHERE ssn="0000000000000000";

SELECT COUNT(firstname)
FROM patients
WHERE firstname="0000000000000000"

SELECT COUNT(lastname)
FROM patients
WHERE lastname="0000000000000000"

etc...
  • 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-25T06:29:56+00:00Added an answer on May 25, 2026 at 6:29 am

    You can do something like this –

    SELECT COUNT(ssn) AS patient_count, 'ssn' AS count_type
    FROM patients
    WHERE ssn="0000000000000000";
    UNION
    SELECT COUNT(firstname) AS patient_count, 'firstname' AS count_type
    FROM patients
    WHERE firstname="0000000000000000"
    UNION
    SELECT COUNT(lastname) AS patient_count, 'lastname' AS count_type
    FROM patients
    WHERE lastname="0000000000000000"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel like i've done this scenario plenty of times, and it usually works,
Usually when I need to fork in C, I do something like this: pid_t
I'm not usually one to just post code and say help, but I feel
I usually indent the public: and private: access specifiers like this: class Foo() {
I use PHP/mySQL/CodeIgniter pretty heavily, writing sql statements to handle/manipulate data. I feel doing
To gain the root permission of android, we usually do like this: Process p=Runtime.getRuntime().exec(su);
I've run into this problem before and the solution has usually been to restart
Usually when I build a site, I put all the CSS into one file,
Usually I tend to install things via the package manager, for unixy stuff. However,
I'm taking several classes this fall for my masters and one of them is

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.