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

  • Home
  • SEARCH
  • 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 8240491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:30:29+00:00 2026-06-07T20:30:29+00:00

how can i count the value of two different column in database? example: i

  • 0

how can i count the value of two different column in database?

example:

i have a table hospital which have a column , hosptal_id and sex

now i want a result that count the the sex column by type, (male or female) within a hospital

i want the result something like..

hospital_id —— F —— M

1 —————– 14—– 45

2 —————– 23—– 49

3 —————– 29—— 76

, how can i get this result?

is anybody can help me on this?

  • 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-07T20:30:30+00:00Added an answer on June 7, 2026 at 8:30 pm
    SELECT id,SUM(IF(sex='M',1,0)) AS 'male', 
    SUM(IF(sex='F',1,0)) AS 'female' 
    FROM hospital 
    GROUP BY id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I count records for two columns in one table using different query
I have a table and can count the number of rows using var count
I have a SQL which can count the condition(Bad,Poor,Worse) in a day and group
How can I add two column value to a list, the two column are
So i need to figure out how i can get a record count value
I can count the rows in the dataset that the table consumes, but this
How can we count space between text in PHP? example: hi how are you?
In SQL Server, I have a table where a column A stores some data.
I have two SQL queries producing different results when I would expect them to
I have two libraries, one of which depends on the other. The first library

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.