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

http://sqlfiddle.com/#!9/b24863/1

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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -