mysql - Sql query count duplicates while grouping them -
i have issue when grouping values in sql.i want count duplicate values each product.also sum qty , cost separately per quarter.i have posted photos below understand better want achieve.
i have applied query based on experience , web:
select products,quarter,count(quarter) table-name group products,quarter;
but output incorrect.
check sample in link below
giving few hints: - sum: aggregation function can used summation - count: used counting
in order sum qty, cost per quarter, query can be:
select quarter, sum(qty), sum(cost) tablename group quarter
to stats per product , quarter, query can be:
select products, quarter, sum(qty), sum(cost) tablename group products, quarter
Comments
Post a Comment