distinct

LINQ Getting Unique items from a List within a List

六月ゝ 毕业季﹏ 提交于 2019-12-23 07:50:55
问题 I have a List of type MyObject with a definition below: class MyObject { public string ListName { get; set; } public IEnumerable<OtherObject> ObjectList { get; set;} } Given a List of type MyObject , using LINQ what expression should I use to get all distinct OtherObject ? What I was planning to do was loop each MyObject and get the distinct OtherObject from the ObjectList property, but then I need to get the distinct across the list. Please note that if: MyObject[0].Objectlist[0] == 'ItemA'

PRODUCED DISTINCT RECORD WITH MULTIPLE FIELDS

前提是你 提交于 2019-12-23 06:08:13
问题 Im trying to figure out how i could pull out the data out of this table: Table: Status OrderNo Status Date User 1 1 2011-07-01 user1 1 2 2011-07-05 user1 2 1 2011-07-01 user1 2 2 2011-07-06 user2 2 3 2011-07-10 user1 and i need to produce the following result: OrderNo Status Date User 1 2 2011-07-05 user1 2 3 2011-07-10 user1 Actually, what i needed is to display DISTINCT list of OrderNo and thier last status. Thanks for all the possible help. Cheers! 回答1: WITH S AS ( SELECT OrderNo, Status,

mySQL >> Adding HREF links to a Distinct GROUP_CONCAT

戏子无情 提交于 2019-12-23 05:25:13
问题 I have the following query: SELECT *, RES.res_id 'ID', RES.RES_Title 'Title', GROUP_CONCAT(DISTINCT T.T_Name separator ', ') 'Topics', GROUP_CONCAT(DISTINCT CH.CH_Code separator ', ') 'Chapters' FROM Resources RES LEFT JOIN topic_to_resource RT ON RT.RT_ResourceID = RES.RES_ID LEFT JOIN topics T on T.T_ID = RT.RT_TopicID LEFT JOIN topic_to_chapter TCH on TCH.TCH_TopicID = T.T_ID LEFT JOIN chapters CH ON CH.CH_ID = TCH.TCH_FrameworkID WHERE RES_Status = 'Active' GROUP BY RES.RES_ID ORDER BY

get latest objects django

自闭症网瘾萝莉.ら 提交于 2019-12-22 19:42:31
问题 I think many similar questions have already been asked, but I could not make up a copy-paste solution. So here is the problem: I periodically compute analysis on my user data for reporting. I made up a model to store these computations in my sqlite database. class report_data(models.Model): name = models.TextField() matrix = PickledObjectField() creation_date = models.DateTimeField('date of creation') I am using an append only scheme, to persist historical data, so there are many records in

get latest objects django

大兔子大兔子 提交于 2019-12-22 19:42:24
问题 I think many similar questions have already been asked, but I could not make up a copy-paste solution. So here is the problem: I periodically compute analysis on my user data for reporting. I made up a model to store these computations in my sqlite database. class report_data(models.Model): name = models.TextField() matrix = PickledObjectField() creation_date = models.DateTimeField('date of creation') I am using an append only scheme, to persist historical data, so there are many records in

SQL Select Distinct column and latest date

丶灬走出姿态 提交于 2019-12-22 13:56:28
问题 I'm looking to select just the latest records of a table based on date, but only one one Distinct listing of each of the urls. The table structure is like this; ID URL DateVisited 1 google.com 01-01-2016 2 yahoo.com 01-02-2016 3 google.com 12-30-2015 4 google.com 02-01-2016 So for my result set I would want google.com 02-01-2016 yahoo.com 01-02-2016 I will have a couple more conditionals in my actual query, but just want to get the single latest records in a hit log, rather than list of

Get distinct values within specific attributes

房东的猫 提交于 2019-12-22 12:00:51
问题 I've got the following XML Code: <!-- language: xml --> <Stats> <Stat> <Data Name="Value">63.76</Data> <Data Name="Entity">first</Data> </Stat> <Stat> <Data Name="Value">51.23</Data> <Data Name="Entity">second</Data> </Stat> <Stat> <Data Name="Value">46.1</Data> <Data Name="Entity">third</Data> </Stat> <Stat> <Data Name="Value">61.21</Data> <Data Name="Entity">first</Data> </Stat> </Stats> I want to filter only where 'Data[@Name='Entity']. Using xpath: /Stats/Stat/Data[@Name="Entity"] returns

PostGres Error When Using Distinct : postgres ERROR: could not identify an ordering operator for type record

我只是一个虾纸丫 提交于 2019-12-22 10:07:45
问题 ** EDIT ** Nevermind, just needed to take out the parens... I get this error: ERROR: could not identify an ordering operator for type record when trying to use DISTINCT Here's the query: select DISTINCT(g.fielda, g.fieldb, r.type) from fields g LEFT JOIN types r ON g.id = r.id; And the errors: ERROR: could not identify an ordering operator for type record HINT: Use an explicit ordering operator or modify the query. ********** Error ********** ERROR: could not identify an ordering operator for

SQLite outer query is returning results not found in inner query

纵饮孤独 提交于 2019-12-22 09:41:24
问题 I just wondered if anyone has run into a case in SQLite (3.7.4) where a query would return one set of results, and when it becomes a subquery the results are completely different? I found the problem in a more complex query, but here's a simpler example that demonstrates the same behavior: Database setup: CREATE TABLE "test" ("letter" VARCHAR(1) PRIMARY KEY, "number" INTEGER NOT NULL); INSERT INTO "test" ("letter", "number") VALUES('b', 1); INSERT INTO "test" ("letter", "number") VALUES('a',

Django ModelChoiceField using distinct values from one model attribute

不羁岁月 提交于 2019-12-22 09:31:39
问题 so I'm working on a django application where I have a model Event. Each Event has some attributes, say one of them is "hostname" (which I will use throughout as an example). I need to implement search functionality where a user can search for all events that has hostname == some_value, e.g. hostname == "myhost.foo.bar". Now, I wanted to allow the user to select among the valid options (i.e. the hostnames that actually exist in one or more event) in a combobox in the search form, so I use