distinct

Specfiy columns which should be considered for distinct calculation

孤街醉人 提交于 2021-02-18 12:18:12
问题 I'm using javax.persistence.criteria.CriteriaBuilder and javax.persistence.criteria.CriteriaQuery to select some entities. I now want to select only the entities that are unique which should be specified by a certain column. There is the method javax.persistence.criteria.CriteriaQuery#distinct which only returns unique entities. I would rather need something like CriteriaQuery<T> distinct(String... columnNames) Do you know how I can bake such a distinct in my JPA CriteriaQuery ? It seems to

C# - how to get distinct items from a Collection View

▼魔方 西西 提交于 2021-02-17 04:30:10
问题 CollectionView view = CollectionView)CollectionViewSource.GetDefaultView(MyData); View.Filter = i => ((MyClass)i).MyProperty; I have a collection view like in the above. The problem is that the collection MyData which has already been bound to a listview contains duplicate items. How do I get unique items as the result of my filtering? 回答1: This method works: CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(c.Items); view.Filter = i => { var index1 = c.MyData

How to make a list in Python distinct based on a property of the class in the list?

一世执手 提交于 2021-02-16 16:07:18
问题 I have a list of instances from the same class, and I want to make my list distinct based on a property in the class. What is the most pythonic way to achieve this? Here is some sample code: #!/usr/bin/python #-*- coding:utf-8 -*- class MyClass(object): def __init__(self, classId, tag): self.classId = classId self.tag = tag myList = [] myInstance1 = MyClass(1, "ABC") myInstance2 = MyClass(2, "DEF") myInstance3 = MyClass(3, "DEF") myList.append(myInstance1) myList.append(myInstance3) # note

How to make a list in Python distinct based on a property of the class in the list?

一曲冷凌霜 提交于 2021-02-16 16:06:56
问题 I have a list of instances from the same class, and I want to make my list distinct based on a property in the class. What is the most pythonic way to achieve this? Here is some sample code: #!/usr/bin/python #-*- coding:utf-8 -*- class MyClass(object): def __init__(self, classId, tag): self.classId = classId self.tag = tag myList = [] myInstance1 = MyClass(1, "ABC") myInstance2 = MyClass(2, "DEF") myInstance3 = MyClass(3, "DEF") myList.append(myInstance1) myList.append(myInstance3) # note

MySQL query to select distinct rows based on date range overlapping

江枫思渺然 提交于 2021-02-11 01:34:07
问题 Let's say we have a table (table1) in which we store 4 values (user_id, name, start_date, end_date) table1 ------------------------------------------------ id user_id name start_date end_date ------------------------------------------------ 1 1 john 2016-04-02 2016-04-03 2 2 steve 2016-04-06 2016-04-06 3 3 sarah 2016-04-03 2016-04-03 4 1 john 2016-04-12 2016-04-15 I then enter a start_date of 2016-04-03 and end_date of 2016-04-03 to see if any of the users are available to be scheduled for a

MySQL query to select distinct rows based on date range overlapping

放肆的年华 提交于 2021-02-11 01:33:24
问题 Let's say we have a table (table1) in which we store 4 values (user_id, name, start_date, end_date) table1 ------------------------------------------------ id user_id name start_date end_date ------------------------------------------------ 1 1 john 2016-04-02 2016-04-03 2 2 steve 2016-04-06 2016-04-06 3 3 sarah 2016-04-03 2016-04-03 4 1 john 2016-04-12 2016-04-15 I then enter a start_date of 2016-04-03 and end_date of 2016-04-03 to see if any of the users are available to be scheduled for a

Rx – Distinct with timeout?

眉间皱痕 提交于 2021-02-10 14:42:14
问题 I’m wondering is there any way to implement Distinct in Reactive Extensions for .NET in such way that it will be working for given time and after this time it should reset and allow values that are come back again. I need this for hot source in application that will be working for whole year with now stops so I’m worried about performance and I need those values to be allowed after some time. There is also DistinctUntilChanged but in my case values could be mixed – for example: A A X A,

Rx – Distinct with timeout?

↘锁芯ラ 提交于 2021-02-10 14:40:24
问题 I’m wondering is there any way to implement Distinct in Reactive Extensions for .NET in such way that it will be working for given time and after this time it should reset and allow values that are come back again. I need this for hot source in application that will be working for whole year with now stops so I’m worried about performance and I need those values to be allowed after some time. There is also DistinctUntilChanged but in my case values could be mixed – for example: A A X A,

Selecting Distinct field and row num just to display an id number gives duplicated data

别来无恙 提交于 2021-02-05 11:23:29
问题 I have a table application and it has 10 columns. category is one column and this column has duplicated values. To get distinct values I have a query SELECT distinct(CATEGORY) as CategoryName FROM APPLICATION where applicationId=? . I am getting result without any issue. Here now I wanted to add a another column as categoryId. There is no such field, I have to generate one. I tried with below query. SELECT distinct(CATEGORY) as CategoryName , rownum as categoryId FROM APPLICATION where

Django queryset - column IN() GROUP BY HAVING COUNT DISTINCT

天大地大妈咪最大 提交于 2021-01-28 17:55:51
问题 With the following models: class Post(models.Model): class Meta: db_table = "posts" class Tag(models.Model): tag = models.CharField(max_length=50) class Meta: db_table = "tags" class PostTag(models.Model): postid = models.PositiveIntegerField() tagid = models.PositiveIntegerField() class Meta: unique_together = ("postid", "tagid") db_table = "posttags" To get postids of posts which contain all the tagids given in TAGLIST where TAGLEN is the number of tagids in TAGLIST: SELECT postid FROM