MySQL Forums
Forum List  »  Newbie

Re: Count and Outptu
Posted by: Vino B
Date: April 12, 2019 09:50AM

Hi Peter,

The table 1 has 3 fields (ok, unreachable, skipped), we have a small program which execute as task and updated the result as below

If the task is successful then update column "ok" with value 1
If the task is Failed then update column "ok" with value 0
If the host is not reachable then update column "unreachable" with value 1
If the task is skipped then update column "skipped" with value 1

So the requirement is find the % for successful/Failed/unreachable/skipped and i am able to get the same using the below SQL statement

SQL Statement:

select sum(a.ok = 1) / t.total * 100 as Successful, sum(a.ok = 0) / t.total * 100 as Failed, sum(a.unreachable = 1) / t.total * 100 as Unreachable, sum(a.skipped = 1) / t.total * 100 as Skipped from status_log as a, (select sum(ok = 1) + sum(ok = 0) + sum(unreachable = 1) + sum(skipped = 1) as total from status_log, run_log where host_id = run_log.id and run_log.host_pattern = 'Dev') as t group by t.total;

Output:

Output:
Successful--------Failed----------Unreachable---------Skipped
28.5714___________28.5714__________28.5714____________28.5714

We need the above out as a list as below

Required format:

Status-------------Percentage
Successful__________ 28.5714
Failed______________ 28.5714
Unreachable_________ 28.5714
Skipped_____________ 28.5714

Table 1:

OK------unreachable----------skipped
1_________1___________________1
1_________0___________________0
0_________0___________________0
0_________1___________________0

From
Vino.B

Options: ReplyQuote


Subject
Written By
Posted
April 11, 2019 10:11PM
April 12, 2019 09:23AM
Re: Count and Outptu
April 12, 2019 09:50AM
April 12, 2019 03:45PM
April 13, 2019 10:42AM
April 13, 2019 10:46AM
April 16, 2019 02:25AM
April 16, 2019 07:39PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.