Dear all
I am new to this topic.I want to count the data from database and also fetch the corresponding value for count....
Code:
public List<PromoCountVO> countPromcoCode(Date FromDate,Date ToDate)
{
List<PromoCountVO> list=null;
try{
System.out.println(FromDate+""+ToDate);
Session session = HibernateUtil.getSession();
list = session.createQuery("SELECT promocode,count(*) FROM PromoCodeVO WHERE userId IN(SELECT userId FROM UserVO WHERE joinDate BETWEEN ? AND ?) GROUP BY promocode").setDate(0, FromDate).setDate(1, ToDate).list();
System.out.println(list.size());
return list;
}
catch(Exception e)
{
System.out.println("PromocodeManager ::countPromcoCode(Date) :" + e);
e.printStackTrace();
}
return null;
}
Please suggestion ,thanks