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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:16:06+00:00 2026-06-12T03:16:06+00:00

I have a big problem with combining 3 SQL queries into one simple query

  • 0

I have a big problem with combining 3 SQL queries into one simple query that returns me all I want. Is tehere any way to join these simple sql queries into one?

query1:

SELECT COUNT(FieldID) AS "CountA"
FROM table WHERE Rezervovany = 0 AND Prodany = 0

query2:

SELECT COUNT(FieldID) AS "CountB"
FROM table WHERE Rezervovany = 1 AND Prodany = 0

query3:

SELECT COUNT(FieldID) AS "CountC"
FROM table WHERE Prodany = 1
  • 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-06-12T03:16:08+00:00Added an answer on June 12, 2026 at 3:16 am

    You can put your conditions in a case clause inside the aggregate count function:

    SELECT Count(CASE 
                   WHEN rezervovany = 0 AND prodany = 0 THEN fieldid 
                   ELSE NULL 
                 END) AS "CountA", 
           Count(CASE 
                   WHEN rezervovany = 1 AND prodany = 0 THEN fieldid 
                   ELSE NULL 
                 END) AS "CountB", 
           Count(CASE 
                   WHEN prodany = 1 THEN fieldid 
                   ELSE NULL 
                 END) AS "CountC" 
    FROM   table 
    

    Keep in mind that count only counts non-null values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a big problem. I want to extract text from html table that
I have a (big) problem that all of you that work with Webforms might
I have a big problem that a recursive treeview doesn't update any childs if
I have a big problem that is I have implemented a scheduler in my
I have a big problem, since today. Before I could insert Guids into this
I have a big problem with an UITableView, I want to use a label
I have a big problem with my server mysql. All worked fine but since
I have an odd problem. There are two databases. One has all products in
The Android documentation being the mess that it is, I have big problem understanding
I have big problem with basic of the Hibernate in all my projects. I

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.