mysql - Group by a field that exist inside a nested query -
i want thank contributing answer here sql fiddle
http://sqlfiddle.com/#!9/610e7/1
-- query return attributes of issue
select * dataissue issue = '25998'
.
what want :
sum(value) count(value) field = 'version(s)_corrigée(s)' , value = 'fermée' , field = 'point_d_effort' , value = 'récit' , group value field = 'version(s)_corrigée(s)'
for example query return group sum explode because use field of outer query :
sqlfiddle.com/#!9/610e7/4
i suspect want this:
select sum(case when field = 'point_d_effort' value + 0 end), v sum(field = 'point_d_effort') cnt dataissue group issue having sum(field = 'version(s)_corrigée(s)' , value = 'fermée') > 0 , sum(field = 'type de demande' , value = 'récit') > 0;
you have entity-attribute-value (eav) data structure. 1 method first aggregate key. if want total across issues, need aggregation:
select sum(v), sum(cnt) (select sum(case when field = 'point_d_effort' value + 0 end), v sum(field = 'point_d_effort') cnt dataissue group issue having sum(field = 'version(s)_corrigée(s)' , value = 'fermée') > 0 , sum(field = 'type de demande' , value = 'récit') > 0 ) t
Comments
Post a Comment