Hi need help on self join and query.
I have a sales_table with sales info and below are the below columns id item_id items_sold sale_time (time stamp)
This table will have all the sales info for a given item id, and how many items sale and at what time it was sale. Now the challenge is i need to generate a summary report of items sold for a month. If want to get using native sql i will do below way.
select tmptable.date_month, sum(tmptable.items_sold) from (select items_sold items_sold, DATE_FORMAT(end_date, '%b %Y') date_month from sales_table) tmptable group by tmptable.date_month
Can some one help me out how to do this using hibernate criteria. As I understand we need a self join and query it.
Thanks in advance.
|