Your local fruit shop hired a bad programmer to build a system for tracking the sales of fruits. However, the programmer fled after implementing the system partially. With the system that the programmer wrote, the owner of the shop only tracks the sales of fruits on each date. But, the owner wants to know the total number of monthly sales for each fruit reported on the last day of each month. Can you help him to write a query that he can run to find out these information?
Input
You will be given a table product
the following columns:
item
:TEXT
date
:DATE
count
:BIGINT
You can assume that the composite fields (item
, date
) will be unique. There will be less than 2000 rows in this table.
Output
Your program needs to output a set with the following columns:
item
:TEXT
date
:DATE
count
:BIGINT
Here, item
is the column for fruits, date
is the last date of each month found in the input table, and count
is the total number of fruits sold on the corresponding month.
The rows should be sorted by item
in alphabetic order and then the date
in increasing order.
Sample
Notes
Do not include a date if there was no record for the corresponding month.