sql - MySQL Query for calculating weightage -
to calculate weightage of faults i've formulated query,
select id,faultdistribution, faulttype, faultseverity, if (faultdistribution='crs', count(id) * 8, 0) + if (faultdistribution='configuration', count(id) * 6, 0) + if (faulttype='bs' , faultseverity='ft', count(id) * 4, 0) + if (faulttype='bs' , faultseverity='mj', count(id) * 2, 0) + if (faulttype='bs' , faultseverity='md', count(id) * 5, 0) + if (faulttype='bs' , faultseverity='mi', count(id) * 3, 0) + if (faulttype='lf' , faultseverity='ft', count(id) * 2, 0) + if (faulttype='lf' , faultseverity='mj', count(id) * 1, 0) tbl_fault product='das' , faultdistribution='missed'
what intend is;
if fault distribution= 'crs' fault * 8 + if fault distribution= 'configuration' fault * 6 .........
as, there records in database not having result above query, help/suggestions required.
regards
becuase using aggregate function count in query returns 1 row.but query running rows 1 one wrong.
the count() function returns number of rows matches specified criteria.
Comments
Post a Comment