tagged [distinct]

How does DISTINCT work when using JPA and Hibernate

How does DISTINCT work when using JPA and Hibernate What column does DISTINCT work with in JPA and is it possible to change it? Here's an example JPA query using DISTINCT: Which doesn't make a lot of ...

23 Jan at 10:21

Is there any difference between GROUP BY and DISTINCT

Is there any difference between GROUP BY and DISTINCT I learned something simple about SQL the other day: Has the same result as: What I am curious of, is there anything different in the way an SQL en...

4 May at 22:19

How to use DISTINCT and ORDER BY in same SELECT statement?

How to use DISTINCT and ORDER BY in same SELECT statement? After executing the following statement: I am getting the following values from the database: but I want the duplicates removed, like this: I...

18 Jul at 00:39

Counting Using Group By Linq

Counting Using Group By Linq I have an object that looks like this: In a `List` I want to output All distinct Name and how many times the particular appears in the collection. For example: I want the ...

21 Oct at 11:38

Java 8 Distinct by property

Java 8 Distinct by property In Java 8 how can I filter a collection using the `Stream` API by checking the distinctness of a property of each object? For example I have a list of `Person` object and I...

How do I (or can I) SELECT DISTINCT on multiple columns?

How do I (or can I) SELECT DISTINCT on multiple columns? I need to retrieve all rows from a table where 2 columns combined are all different. So I want all the sales that do not have any other sales t...

Pandas 'count(distinct)' equivalent

Pandas 'count(distinct)' equivalent I am using Pandas as a database substitute as I have multiple databases ([Oracle](https://en.wikipedia.org/wiki/Oracle_Database), [SQL Server](https://en.wikipedia....

30 Aug at 08:1

Laravel Eloquent - distinct() and count() not working properly together

Laravel Eloquent - distinct() and count() not working properly together So I'm trying to get the number of distinct pids on a query, but the returned value is wrong. This is what I try to do: what ret...

21 Feb at 21:44

LINQ Select Distinct with Anonymous Types

LINQ Select Distinct with Anonymous Types So I have a collection of objects. The exact type isn't important. From it I want to extract all the unique pairs of a pair of particular properties, thusly: ...

Removing duplicates from a SQL query (not just "use distinct")

Removing duplicates from a SQL query (not just "use distinct") It's probably simple, here is my query: but this will only remove duplicates where a row has both the same u.name and p.pic_id. I want it...

7 Feb at 03:56

sql group by versus distinct

sql group by versus distinct Why would someone use a group by versus distinct when there are no aggregations done in the query? Also, does someone know the group by versus distinct performance conside...

Linq Distinct() by name for populate a dropdown list with name and value

Linq Distinct() by name for populate a dropdown list with name and value I'm trying to populate a Drop down list with pharmaceutical companies, like Bayer, Medley etc. And, I'm getting theses names fr...

29 Mar at 17:26

Get a list of distinct values in List

Get a list of distinct values in List In C#, say I have a class called `Note` with three string member variables. And I have a list of type `Note`: What would be the cleanest way to get a list of all ...

14 Jul at 18:43

How to select records without duplicate on just one field in SQL?

How to select records without duplicate on just one field in SQL? I have a table with 3 columns like this: There are many records in this table. Some of them have `state` and some other don't. Now, i...

28 Apr at 07:2

Use a delegate for the equality comparer for LINQ's Distinct()

Use a delegate for the equality comparer for LINQ's Distinct() I have a LINQ Distinct() statement that uses my own custom comparer, like this: ``` class MyComparer : IEqualityComparer where T : MyType...

18 Oct at 15:14

Entity Framework returning distinct records issue

Entity Framework returning distinct records issue I have a PC Enity which have some Properties , I would like to return a list of distinct Object (PC or Complex Type or whatever ) based on a property ...

linq distinct or group by multiple properties

linq distinct or group by multiple properties How can I using c# and Linq to get a `result` from the next list: ``` var pr = new List() { new Product() {Title="Boots",Color="Red", Price=1}, ne...

14 Dec at 10:56

How to create a HashSet<List<Int>> with distinct elements?

How to create a HashSet> with distinct elements? I have a HashSet that contains multiple lists of integers - i.e. `HashSet>` In order to maintain uniqueness I am currently having to do two things: 1. ...

Distinct a list with objects by id

Distinct a list with objects by id I have a program where there is a topic (like a forum), people can react to that topic. USER: 1. id 2. first name 3. last name TOPIC: 1. id 2. subject REACTION: 1. i...

2 May at 02:54

Use LINQ to select distinct properties in Lists of Lists

Use LINQ to select distinct properties in Lists of Lists I want to use LINQ to select a unique list of strings, stored as a List, inside an object. This object is itself stored in a List inside anothe...

16 Apr at 15:52

Most efficient way to remove duplicates from a List

Most efficient way to remove duplicates from a List Let's say I have a List with duplicate values and I want to remove the duplicates. I have found 3 approaches to solve this: ``` List result1 = new H...

23 May at 05:41

LINQ's Distinct() on a particular property

LINQ's Distinct() on a particular property I am playing with LINQ to learn about it, but I can't figure out how to use [Distinct](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.di...

18 Jan at 13:19

Why is there no Linq method to return distinct values by a predicate?

Why is there no Linq method to return distinct values by a predicate? I want to get the distinct values in a list, but not by the standard equality comparison. What I want to do is something like this...

6 Feb at 11:51

How to implement IEqualityComparer to return distinct values?

How to implement IEqualityComparer to return distinct values? I have a L2E query that returns some data that contains duplicate objects. I need to remove those duplicate objects. Basically I should as...

Implementing IEqualityComparer<T> on an object with two properties in C#

Implementing IEqualityComparer on an object with two properties in C# I have a case where I need to grab a bunch of items on distinct, but my source is a collection of objects with two properties, lik...

21 May at 10:24