distinct

SQL Select Distinct column and latest date

元气小坏坏 提交于 2019-12-06 09:47:20
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 distinct urls and dates, just distinct url's and the latest date. This is actually pretty easy to do using

SQL Server Select Distinct

那年仲夏 提交于 2019-12-06 08:01:09
问题 I want to write a query like this: For a table that has these columns: ColA ColB ColC, ColD select first(ColA, ColB, ColC, ColD) distinct(ColB, ColC) from table order by ColD The query is supposed to order the table by ColD, then group the results by the combination of ColB and ColC (they may have different data types) and returns the first rows (with all the columns of the table) in the groups. How is it possible in MS SQL Server 2005? 回答1: It sounds like you want 'max per group'. One way is

XQuery distinct values with where clause problem

一个人想着一个人 提交于 2019-12-06 07:23:40
I'm very new to XQuery so excuse me if I am somehow missing something. I am trying to extract data where certain sub-nodes of an element are DISTINCT, as well as where a certain sibling node's is equal to some predefined string for $product in fn:distinct-values(document('cpwdoc')/root/package/properties/value[@key="product"]) where document('cpwdoc')/root/package/categories/category[@name="Cheap"] return $product The XML I am querying looks like this: <root> <package> <title>Some package 1</title> <categories><category group="Other" name="Cheap"/></categories> <properties> <value key="product

Create MySQL view using distinct values as columns

℡╲_俬逩灬. 提交于 2019-12-06 04:34:27
I have searched a while and can't find an answer to my problem. I have a table that looks like this: date name status 2011-01-01 m1 online 2011-01-01 m2 offline 2011-01-01 m3 online 2011-01-02 m1 offline 2011-01-02 m2 offline 2011-01-02 m3 online I want to create a view that will looks like the following: date m1 m2 m3 2011-01-01 online offline online 2011-01-02 offline offline online Where values under the the 'name' column are distinct and has a fixed number of values, say 20 different values (m1 ... m20), but can be increased as times goes. Is it possible to create a view like this? if yes,

How to extract distinct values from a mongo database using Waterline and Sails.js (version 0.10)?

好久不见. 提交于 2019-12-06 04:25:50
Using Sails.js version 0.10.x , assume I have a model Dog , populated as follows (writtenout in yaml format for convenience, but in my case it's actually in a mongo database.) dogs: - breed: "wolf" name: "Fido" - breed: "wolf" name: "Roger" - breed: "dingo" name: "Nipper" - breed: "dingo" name: "Ernie" - breed: "corgi" name: "Bernadi" - breed: "corgi" name: "Queenie" - breed: "poodle" name: "Christopher" - breed: "poodle" name: "Tony" etc So now I want to create a list of the available breeds. Dog.find().exec(err, dogs) { breeds = []; dogs.each(function(dog)) { if (breeds.indexOf(dog.breed) ==

Group by clause vs. Distinct() [closed]

删除回忆录丶 提交于 2019-12-06 04:14:21
Closed. This question is off-topic . It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . My ASP.NET custom list control gets its values from a database View . The method which retrieves data finally returns an object of type List<Triplet> as a DataSource for the control. I figured out three possible implementations for that method which all seem to work fine and give the same results. Now I'm not sure which of them should be preferred. The point is, that I need unique strings from the query in

How Get distinct value node XML

笑着哭i 提交于 2019-12-06 04:07:34
问题 I am new in XML, so I hope your help. I have the following XML: <?xml version="1.0" encoding="UTF-8"?> <Students> -<Student Id="001"> <Name>Peter</Name> <LastName>Kohen</LastName> -<Courses> -<Course Id="01"> <Name>C#</Name> </Course> -<Course Id="02"> <Name>Java</Name> </Course> </Courses> </Student> -<Student Id="002"> <Name>Nick</Name> <LastName>Nikes</LastName> -<Courses> -<Course Id="02"> <Name>Java</Name> </Course> -<Course Id="03"> <Name>Oracle</Name> </Course> </Courses> </Student> -

Select distinct entities by specific column

给你一囗甜甜゛ 提交于 2019-12-06 03:54:37
I have a table with 4 columns : id, column_a and column_b My initial query is basicaly Session session = initialize my hibernate session; Criteria criteria = session.createCriteria(MytableBean.class); // add some constraints return criteria.list() And it returns some results like : id | column_a | column_b | 1 | A | 1 | 2 | A | 1 | 3 | A | 2 | 4 | B | 3 | 5 | B | 3 | But I don't want to get several times the same couple (column_a, column_b), even if I need to have it many times in my database. So, I'm looking for a query which returns a result similar to: id | column_a | column_b | | A | 1 | |

spark shell操作

亡梦爱人 提交于 2019-12-06 03:17:37
RDD有两种类型的操作 ,分别是Transformation(返回一个新的RDD)和Action(返回values)。 1.Transformation:根据已有RDD创建新的RDD数据集build (1)map(func):对调用map的RDD数据集中的每个element都使用func,然后返回一个新的RDD,这个返回的数据集是分布式的数据集。 (2)filter(func) :对调用filter的RDD数据集中的每个元素都使用func,然后返回一个包含使func为true的元素构成的RDD。 (3)flatMap(func):和map很像,但是flatMap生成的是多个结果。 (4)mapPartitions(func):和map很像,但是map是每个element,而mapPartitions是每个partition。 (5)mapPartitionsWithSplit(func):和mapPartitions很像,但是func作用的是其中一个split上,所以func中应该有index。 (6)sample(withReplacement,faction,seed):抽样。 (7)union(otherDataset):返回一个新的dataset,包含源dataset和给定dataset的元素的集合。 (8)distinct([numTasks])

Returning distinct values from foreach loop in PHP?

徘徊边缘 提交于 2019-12-06 01:42:22
问题 I have a foreach loop which echo 's each of the property types in my search results. The code is as follows: <?php foreach($search_results as $filter_result) { echo $filter_result['property_type']; } ?> The above code returns: house house house house flat flat flat I would like to do something similar to the MySQL 'distinct', but I am not sure how to do it on a foreach statement. I want the above code to return: house flat Not repeat every item each time. How can I do this? 回答1: Try with: