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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:47:55+00:00 2026-05-29T03:47:55+00:00

I have two mysql table: Defects df_id | project_id | resp_id | status ——+————+———+———-

  • 0

I have two mysql table:

Defects

df_id | project_id | resp_id | status
------+------------+---------+----------
1     |     1      |    1    |  Open 
2     |     1      |    1    |  Open
3     |     1      |    1    |  Closed
4     |     1      |    2    |  Open
5     |     1      |    2    |  Closed

Responsible

resp_id | resp_comp_name
--------+----------------
   1    |     Google
   2    |     Firefox

and I require output

resp_comp_name | open | closed
---------------+------+--------
  Google       |  3   |    1
  Firefox      |  1   |    1

I wrote:

     SELECT r.resp_comp_name, d.status, COUNT(d.df_id) AS total
       FROM pms_defects d
  LEFT JOIN pms_responsibles r ON d.resp_id=r.resp_id
      WHERE d.project_id='1' AND d.resp_id != 0
   GROUP BY d.resp_id
   ORDER BY total DESC

it produce:

enter image description here

  • 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-29T03:47:56+00:00Added an answer on May 29, 2026 at 3:47 am
    SELECT r.resp_comp_name, sum(if(d.status = 'Open',1,0)) as open, 
    sum(if(d.status ='Closed',1,0)) as closed from pms_defects d, pms_responsibles r 
    where r.resp_id = d.resp_id group by d.resp_id 
    

    This uses if statements and sum to move open/closed from row- to column-based.

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

Sidebar

Related Questions

using php and mysql I have two tables, a users table and a profiles
i work with php/Mysql i have table with two cols (date , cash) with
I am using MYSQL and PHP. I have a table called item. Two of
I have two jobs pulling from a mysql table. They both want to get
I have two MySQL tables a and b with fields x and y. Table
I have two servlets: LoginServlet and MailServlet. LoginServlet queries a mysql table using jdbc
I have two mySQL tables as follows: [product] table P_id | Name | Quantity
I have two MySql tables as shown below with the data shown: CREATE TABLE
I have two tables on mysql: users, and management. The users table has a
I have two MySQL databases with identical table structure, each populated with several thousand

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.