I'm building a web application that has a search engine. I'm using NetBeans ( Java ) and SQL databases.
I'm trying to (group by) the results of a search engine. So I don't get duplicate results and use COUNT to rank the results. I'm having a problem writing it.
Query query = em.createQuery("select s.name from Searchresult s");
this WORKS for getting the name and this one works as well for grouping the results by name
Query query = em.createQuery("select s.name from Searchresult s group by s.name");
but this one doesn't
Query query = em.createQuery("select s.name, count(s.name) from Searchresult s group by s.name");
It doesn't work whenever i'm trying to add any other field (having more than one)
Query query = em.createQuery("select s.name, s.description from Searchresult s group by s.name");
^ so this one doesn't work too
How can I write a query in that gets more than one field (name, description, url) and get the count(name) and group by the result by names?