Code:
Session session = null;
// -> the session is null here.. that's why it throw null pointer exception
// -> you should create a session with SessionFactory
Query query = session.createQuery("select count(*) from poll_results where asnwer_id like '%'");
//you should do this instead:
//int count = ((Number)query.list().get(0).intValue();
int count = ((Number) query.list()).intValue();
Query query1 = session.createQuery("select count(*) from poll_results where question_id like '%");
//int count1 = ((Number)query.list().get(0)).intValue();
int count1 = ((Number) query.list()).intValue();
int result = (count/count1)*100;
return result;