MySQL query - Invalid Use of Group Function - Using SUM -


i having "invalid use of group function" error while executing following query.

select id, faultdistribution, faulttype, faultseverity,  sum(if (faultdistribution='crs', sum(if(faultdistribution='crs',1,0))*8, 0)+ if (faultdistribution='configuration', sum(if(faultdistribution='configuration',1,0))* 6, 0)+ if (faulttype='business' , faultseverity='fatal', sum(if(faulttype='business' , faultseverity='fatal',1,0))* 4, 0)+ if (faulttype='business' , faultseverity='major', sum(if(faulttype='business' , faultseverity='major',1,0))* 2, 0)+ if (faulttype='business' , faultseverity='moderate', sum(if(faulttype='business' , faultseverity='moderate',1,0))* 5, 0)+ if (faulttype='business' , faultseverity='minor', sum(if(faulttype='business' , faultseverity='minor',1,0))* 3, 0)+ if (faulttype='look & feel' , faultseverity='fatal', sum(if(faulttype='look & feel' , faultseverity='fatal',1,0))* 2, 0)+ if (faulttype='look & feel' , faultseverity='major', sum(if(faulttype='look & feel' , faultseverity='major',1,0))* 1, 0)) tbl_fault product='das' , faultdistribution='missed' 

where doing wrong? kindly help!

sum(), count(), avg(), min(), max(), etc. aggregate functions requires specify group by, unless you're using them on every column in select-list.

in case, query should work adding following @ bottom:

group id, faultdistribution, faulttype, faultseverity 

...but judging many nested if's have, i'm not entirely sure give output you're looking for.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -