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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:55:18+00:00 2026-06-17T06:55:18+00:00

I have a call logging database that I would like to pull team information

  • 0

I have a call logging database that I would like to pull team information from. It is running on an old MySQL 4.0.16 server so I am struggling to get the data without subqueries/views and am looking for a push in the right direction as I am still quite new to MySQL/PHP.

The source table is in the form of:

callid | team   | status
---------------------------
15432  | team A | open
15433  | team B | open
15434  | team A | onhold
15435  | team A | closed
15436  | team A | closed

and I would like to output the number of calls per team per status so it should look like:

team   | open | onhold | closed
--------------------------------
team A | 1    | 1      | 2
team B | 1    | 0      | 0

This can either be in a select statement or a using a temp table and multiple queries as either of these will allow me to use the data to display overall team information.

I’ve created temp table and filled it with the team names and zeros for the number of onhold etc but am then failing to come up with an update statement that will then add the number calls per status per team without a subquery. What is the best way of going about this in MySQL 4.0.16? Thank you for any help you can provide.

  • 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-17T06:55:19+00:00Added an answer on June 17, 2026 at 6:55 am

    You can use an aggregate function with a case expression to get the data in the format that you want:

    select team,
      sum(case when status = 'open' then 1 else 0 end) Open,
      sum(case when status = 'onhold' then 1 else 0 end) Onhold,
      sum(case when status = 'closed' then 1 else 0 end) Closed
    from yourtable
    group by team
    

    See SQL Fiddle with Demo

    Result is:

    |   TEAM | OPEN | ONHOLD | CLOSED |
    -----------------------------------
    | team A |    1 |      1 |      2 |
    | team B |    1 |      0 |      0 |
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a call to powershell.exe that looks like this, and which works from
I have a database call that i am not sure if i am doing
I have a call like this: $(#ContextMenuModal).height($(body).height()); However $(body).height() returns undefined when I view
I have a call back url, that i'm am pulling out the Lat and
Currently I have a static class that I use as my logging module. I’ve
The situation here is that I have a web sql database with 8 tables
I have a C++ class that is the frontend for a logging system. Its
I recently did an import of database from a sql server 2000 database to
I have setup an Application that uses @Anywhere from twitter to Authenticate the users.
I have a call to TraceSource.TraceEvent() that is sometimes not writing to the Azure

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.