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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:14:00+00:00 2026-06-07T01:14:00+00:00

I have two database tables containing similar data – one is the amount of

  • 0

I have two database tables containing similar data – one is the amount of work completed by a process, the other is the amount of errors made by that process.

I would like to display the percentage of right first time work.

My query for counting the number of items by process is:

SELECT Counter.Process, count( Counter.Process ) AS count
                            FROM Counter WHERE (TIME BETWEEN '2012-07-01 00:00:00' AND '2012-07-06 23:59:59')
                            GROUP BY Counter.Process
                            ORDER BY count DESC

The above gives me a list similar to:

Process    | count
-------------------
Process A  | 40
Process B  | 32
Process C  | 102
Process D  | 23

I have a second table with the same fields in it for recording errors, called ‘Errors’.

By using the same query (but changing the table names obviously) I can get a list of processes and errors.

What I want to do is create a PHP web page showing the percentage of errors per process.

My problem is if I create the two queries separately, when I loop through them using a PHP Where loop I don’t know how to make the calculation to show the percentage.

I tried using a UNION between the two SQL queries, but I can’t get it to show the two different count readings against the process.

Ideally, I’d like a way to show the data like this:

Process   | Counter.count | Errors.count
Process A     40              2
Process B     32              0
Process C     102             18
Process D     23              8

I would really appreciate any advice/suggestions as to how I can accomplish this – if you need more info on my database tables, please let me know

Thanks for reading

S

  • 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-07T01:14:03+00:00Added an answer on June 7, 2026 at 1:14 am

    You could use a sub-query:

    SELECT Counter.Process, count( Counter.Process ) AS Count,
          (SELECT count(Errors.Process) 
             FROM Errors
            WHERE Process=Counter.Process 
              AND (TIME BETWEEN '2012-07-01 00:00:00' AND '2012-07-06 23:59:59')) AS Errors
                                FROM Counter WHERE (TIME BETWEEN '2012-07-01 00:00:00' AND '2012-07-06 23:59:59')
                                GROUP BY Counter.Process
                                ORDER BY count DESC
    

    Regards,
    Neil.

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

Sidebar

Related Questions

I have two database tables, one for Users of a web site, containing the
i have two tables in my database one is A other one is B
I have two MySQL database tables: one containing a list of championships and another
I have a database containing two tables: event and session (one event has multiple
I have a database containing two tables - one, states, contains info about each
I have two tables in my MySQL database, one is a library of all
I have two tables inside a database. One stores unique userNames and a unique
I have two tables, one containing cities and one containing countries. Every city is
I have two tables containing two different kinds of comments. One of the tables
I have two database tables, 1st is the TABLE_GLOBAL_PRODUCTS where all products information are

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.