distinct

XSLT select only last version element in rowset

£可爱£侵袭症+ 提交于 2019-12-11 09:18:35
问题 My xml is: <RowSet> <Row> <msg_id>1</msg_id> <doc_id>1</doc_id> <doc_version>1</doc_version> </Row> <Row> <msg_id>2</msg_id> <doc_id>1</doc_id> <doc_version>2</doc_version> </Row> <Row> <msg_id>3</msg_id> <doc_id>1</doc_id> <doc_version>3</doc_version> </Row> <Row> <msg_id>4</msg_id> <doc_id>2</doc_id> <doc_version>1</doc_version> </Row> <RowSet> What I need to do: If there are Rows with the same doc_id , I need to select only node with the bigger doc_version number. Expected output: <RowSet>

Linq to Entities Distinct on Column without Anonymous Type

白昼怎懂夜的黑 提交于 2019-12-11 08:37:47
问题 I am using Entity Framework 5.0 and I wish to return a list of objects, however, I want to perform a DISTINCT on one of the properties on each object within the list. I know there are a few questions similar to mine already on Stackoverflow , however, I am still struggling with this one. Currently my query looks like this public IList<tblcours> GetAllCoursesByOrgID(int id) { return _UoW.tblcoursRepo.All.Where(c => c.tblCourseCategoryLinks.Any(cl => cl.tblUnitCategory.tblUnit.ParentID == id))

Show top N rows by category in MySQL 8 without duplicates in another category

别说谁变了你拦得住时间么 提交于 2019-12-11 08:04:01
问题 Similar to this question, I have the following table in MySQL 8.0.15: CREATE TABLE golf_scores (id INT PRIMARY KEY AUTO_INCREMENT, person TEXT, score INT, age INT); INSERT INTO golf_scores (person, score, age) VALUES ('Angela', 40, 25),('Angela', 45, 25),('Angela', 55, 25),('Peter',45, 32),('Peter',55,32),('Rachel', 65, 35),('Rachel',75,35),('Jeff',75, 16); SELECT * FROM golf_scores; +----+--------+-------+------+ | id | person | score | age | +----+--------+-------+------+ | 1 | Angela | 40

Hibernate - Distinct Query returning two columns result

房东的猫 提交于 2019-12-11 07:58:40
问题 Sometime back I asked the question regarding how to do a Distinct query using Hibernate. Now that I'm past that milestone, there is another thing that I require. And that is, given the table, --------------------------------------- | user_id | user_name | user_type | --------------------------------------- | 1 | mark taylor | admin | | 2 | bill paxton |co-ordinator| | 1 | tony brooks | admin | | 3 | ali jahan | developer | --------------------------------------- I want to create a distinct

SQL-Query needed to find distinct IDs probably using IN and NOT IN

∥☆過路亽.° 提交于 2019-12-11 07:05:17
问题 Let's pretend I have a large recipe-database. A table for recipes each with an unique ID and a table for ingredients with a whole lot of sets like this: ID | RECIPE | INGREDIENT ------------------------------- 1 | recipe_a | ingredient_a 2 | recipe_a | ingredient_b 3 | recipe_a | ingredient_c 4 | recipe_b | ingredient_a 5 | recipe_b | ingredient_d 6 | recipe_b | ingredient_e Users can search for ingredients they want to see in their recipes and those they don't. The wanted query should be

Unexpected effect of filtering on result from crosstab() query

不羁岁月 提交于 2019-12-11 06:47:52
问题 I have a crosstab() query like the following: SELECT * FROM crosstab( 'SELECT row_name, extra1, extra2..., another_table.category, value FROM table t JOIN another_table ON t.field_id = another_table.field_id WHERE t.field = certain_value AND t.extra1 = val1 ORDER BY row_name ASC', 'SELECT category_name FROM category_name WHERE field = certain_value' ) AS ct(row_name text, extra1 text, extra2 text, ...) Simplified example, the actual query is really complex and contains important information.

Unique combination per group

爷,独闯天下 提交于 2019-12-11 06:05:03
问题 I have a DT with three columns, and the two first ones have various values grouped by Group. ID ID_2 Group 23201600101793 2016052016051062331 A 23201600101793 2016062016061017838 A 23201600101794 2016052016051062331 A 23201600101794 2016052016051062402 A 23201600103090 2016052016051062325 A 23201600103090 2016052016051062408 A 23201600803366 2016052016051062325 A 23201600803366 2016052016051062408 A I need to find a unique combination of both columns, withtout repeated values in any column.

Count duplicate cell values as one if multiple criteria are met

爱⌒轻易说出口 提交于 2019-12-11 05:56:42
问题 I am trying to get the total count of entries per month based on the status ("Settled") and the distinct code . If the other status of the other entries in that certain code is not yet settled, it shouldn't count. Please see example below and the expected output. MONTH |CODE |CONTRIBUTION|STATUS JANUARY |CS-111|500 |Settled JANUARY |CS-111|500 |Settled FEBRUARY|CS-131|200 |Settled FEBRUARY|CS-131|200 |Waiting FEBRUARY|CS-141|300 |Settled MARCH |CS-151|400 |Waiting MARCH |CS-161|700 |Settled

Combining SELECT DISTINCT with UNION DISTINCT in MySQL - any effect?

≯℡__Kan透↙ 提交于 2019-12-11 05:23:48
问题 The following two SQL statements are functionally identical: SELECT DISTINCT a,b,c FROM table1 UNION DISTINCT SELECT DISTINCT a,b,c FROM table2 and SELECT a,b,c FROM table1 UNION DISTINCT SELECT a,b,c FROM table2 ...because "DISTINCT" is applied to the union as a whole, and so is redundant within the individual SELECT 's. (NOTE: UNION DISTINCT is identical to just UNION by itself, but I included the DISTINCT keyword for clarity) My question here is, is there a performance difference, or

DISTINCT a column in a database

时光毁灭记忆、已成空白 提交于 2019-12-11 05:17:26
问题 I'm trying to perform a DISTINCT clause on a query like this SELECT DISTINCT username, wiki.text, wiki.date FROM wiki_house INNER JOIN wiki ON wiki_house.wiki_id = wiki.id INNER JOIN users ON wiki.user_id = users.id AND wiki_house.house_id = 1 AND wiki.language = 'it' ORDER BY wiki.date DESC LIMIT 10 this returns: username wiki.text wiki.date mike Hello 2010-03-09 mike Helo 2010-03-08 kim Whats... 2010-03-07 mike When in... 2010-03-06 eddy Hel 2010-03-05 I thought this query should returned