Reputation: 7
Can you help me, i have problem with my query. i have data like bellow :
+------------+---------+-----+
| Date | Prod_ID | Qty |
+------------+---------+-----+
| 01/02/2018 | Pencil | 2 |
| 01/02/2018 | pencil | 3 |
| 01/02/2018 | pencil | 4 |
| 01/02/2018 | book | 5 |
| 01/02/2018 | ruller | 1 |
+------------+---------+-----+
but my result as bellow
+------------+---------+-----+
| Date | Prod_ID | Qty |
+------------+---------+-----+
| 01/02/2018 | 5 | 15 |
+------------+---------+-----+
i need my result bellow
+------------+---------+-----+
| Date | Prod_ID | Qty |
+------------+---------+-----+
| 01/02/2018 | 3 | 15 |
+------------+---------+-----+
bellow my query script
select "date",
Prod_ID,
Qty,
from data
group by "date",
Prod_ID,
Qty,
order by "date";
Thank You,
Upvotes: 0
Views: 45
Reputation: 1433
You can try the following:
select "date",
Count(Distinct Prod_ID) as total_product_count,
Sum(Qty) as qty
from
data
group by
"date"
order by "date";
Upvotes: 2