Hibernate native SQL query with GROUP BY Clause

See the example of Hibernate native SQL query with GROUP BY Clause, Also this query contains the logic to retrieve the data in a date range in mysql

Query query = this.sessionFactory.getCurrentSession().createSQLQuery(
           "SELECT expenseHead, sum(expense) FROM mb.expense where date<=':date2' and date>= ':date1' group by expenseHead;")
           .setParameter("date2", date2)
           .setParameter("date1", date1);
           List result = query.list();
         return result;