I have a table like:
id|column_1|column_2|column_3|
0| A | 100 | 10 |
1| B | 100 | 20 |
2| C | 1000 | 10 |
3| D | 100 | 10 |
and i want to query such that i want distinct(column_2 and column_3), means combination of column_2 and column_3 have to be distinct . So the result I want is like:
id|column_1|column_2|column_3|
0| A | 100 | 10 |
1| B | 100 | 20 |
2| C | 1000 | 10 |
I'm using STS MVC & hibernate4, with mysql. Any suggestion is appreciated.
Code I'm using right now is:
Session ses=sf.getCurrentSession();
Criteria criteria=ses.createCriteria(myclass.class);
ProjectionList projList = Projections.projectionList();
projList.add(Projections.property("column_2"));
projList.add(Projections.property("column_3"));
criteria.setProjection(Projections.distinct(projList));
but its just returning the distinct values, i want the complete row.
Try this one:
select column1, column2, column3 from table group by column2, column3
Regards, Arun
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.