distinct in Xpath?
A pure XPath 1.0 — one-liner: Use: count(/*/group/user[not(. = ../following-sibling::group/user)])
A pure XPath 1.0 — one-liner: Use: count(/*/group/user[not(. = ../following-sibling::group/user)])
Use a terms aggregation on the color field. And you need to pay attention to how that field you want to get distinct values on is analyzed, meaning you need to make sure you’re not tokenizing it while indexing, otherwise every entry in the aggregation will be a different term that is part of the … Read more
An EqualityComparer is not the way to go – it can only filter your result set in memory eg: var objects = yourResults.ToEnumerable().Distinct(yourEqualityComparer); You can use the GroupBy method to group by IDs and the First method to let your database only retrieve a unique entry per ID eg: var objects = yourResults.GroupBy(o => o.Id).Select(g … Read more
Try this: SELECT MIN(id) AS id, title FROM tbl_countries GROUP BY title
How about simply: select distinct c1, c2 from t or select c1, c2, count(*) from t group by c1, c2
It’s groups by needed properties and select: List<Product> result = pr.GroupBy(g => new { g.Title, g.Price }) .Select(g => g.First()) .ToList();
To do a distinct on only one (or n) column(s): select distinct on (name) name, col1, col2 from names This will return any of the rows containing the name. If you want to control which of the rows will be returned you need to order: select distinct on (name) name, col1, col2 from names order … Read more
This is where the window function row_number() comes in handy: SELECT s.siteName, s.siteIP, h.date FROM sites s INNER JOIN (select h.*, row_number() over (partition by siteName order by date desc) as seqnum from history h ) h ON s.siteName = h.siteName and seqnum = 1 ORDER BY s.siteName, h.date
This can be done very simple, you were pretty close already SELECT distinct id, DENSE_RANK() OVER (ORDER BY id) AS RowNum FROM table WHERE fid = 64
You can achieve the desired result by requesting a list of distinct ids instead of a list of distinct hydrated objects. Simply add this to your criteria: criteria.setProjection(Projections.distinct(Projections.property(“id”))); Now you’ll get the correct number of results according to your row-based limiting. The reason this works is because the projection will perform the distinctness check as … Read more