I have a query that need to do something like this.
About the data:
-----
I have a rules table which has got all the rules, and a log table that has the logs which says whether the rules are satisfied or not over a point of time.
select rules, sum(decode(status,'pass','1')) as passed, sum(decode(status,'fail',1)) as failed from rulestable,logstable where rulestable.logid=logstable.id
My expected Output
----------
Rule1 passed= 10 failed=12
Rule2 passed=11 failed=15
But i donot have decode() function in mssql nor can I use IF ELSE here. Can anyone please tell me how this can be implemented here?
Thanksselect rules, sum(decode(status,'pass','1')) as passed, sum(decode(status,'fail',1)) as failed from rulestable,logstable where rulestable.logid=logstable.id
But i donot have decode() function in mssql nor can I use IF ELSE here. Can anyone please tell me how this can be implemented here?
Thanks select rules,
sum(CASE status WHEN 'pass' THEN 1 ELSE 0 END) as passed,
sum(CASE status WHEN 'failed' THEN 1 ELSE 0 END) as failed
from rulestable INNER JOIN logstable ON rulestable.logid=logstable.id
ANSII Joins used too. HTH|||Thanks a lot. It worked.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment