distinct

SQL Server TOP(1) with distinct

匿名 (未验证) 提交于 2019-12-03 08:57:35
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to extract the first row I get after ordering the result by i_version_id . If I do not use TOP(2) , my query works as expected ans returns all results sorted by i_version_id. But when I add the TOP(2) (as shown below), it says that there is a syntax error near distinct . Please let me know what I am doing wrong. SELECT TOP(2) distinct(i_version_id) FROM [PaymentGateway_2006].[dbo].[merchant] WHERE dt_updated_datetime > '2013-11-11' GROUP BY i_version_id ORDER BY i_version_id; 回答1: If you're only getting the TOP 1 then distinct is

pyspark: count distinct over a window

匿名 (未验证) 提交于 2019-12-03 08:57:35
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I just tried doing a countDistinct over a window and got this error: AnalysisException: u'Distinct window functions are not supported: count(distinct color#1926) Is there a way to do a distinct count over a window in pyspark? Here's some example code: from pyspark.sql import functions as F #function to calculate number of seconds from number of days days = lambda i: i * 86400 df = spark.createDataFrame([(17, "2017-03-10T15:27:18+00:00", "orange"), (13, "2017-03-15T12:27:18+00:00", "red"), (25, "2017-03-18T11:27:18+00:00", "red")], ["dollars"

How to fetch distinct values with arel/relational algebra and has_many :through

匿名 (未验证) 提交于 2019-12-03 08:57:35
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When I try to display all movies that a person is in, and they have more than 1 role (director,writer,actor) in a movie, I get multiple lines for that movie. If I add .select('DISTINCT id') or movies.* to try and eliminate the dups I get the following error: Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DISTINCT id FROM movies INNER JOIN movie_people ON movies .id = movie_peop' at line 1: SELECT movies .*, DISTINCT id FROM movies INNER

Neo4j slower than MySQL in performing recursive query

匿名 (未验证) 提交于 2019-12-03 08:57:35
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I would like to compare Neo4j( ver. 3.1 ) and MySQL in performing recursive queries. Therefore I created two tables in MySQL database - Customer and CustomerFriend . Second table consists of CustomerID and FriendID columns, both of them point to CustomerID column in Customer table. In Neo4j were created corresponding entities: Customer nodes and FRIEND_OF relations (c:Customer)-[f:FRIEND_OF]->(cc:Customer) . Databases are filled with the same data: 100000 Customers, each Customer has 100 relations. Executed below queries: MySQL ( 60s )

How to get distinct rows in dataframe using pyspark?

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I understand this is just a very simple question and most likely have been answered somewhere, but as a beginner I still don't get it and am looking for your enlightenment, thank you in advance: I have a interim dataframe: +----------------------------+---+ |host |day| +----------------------------+---+ |in24.inetnebr.com |1 | |uplherc.upl.com |1 | |uplherc.upl.com |1 | |uplherc.upl.com |1 | |uplherc.upl.com |1 | |ix-esc-ca2-07.ix.netcom.com |1 | |uplherc.upl.com |1 | What I need is to remove all the redundant items in host column, in

Return unique/distinct values with Realm query

匿名 (未验证) 提交于 2019-12-03 08:42:37
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a Message/RLMObject model that has a NSString *jabberID property/row and I want to retrieve every unique value inside that row. In other word, I want to retrieve non-repeated jabberID values from my Message model. Can anyone help out figuring this? The way I use to do with coredata was using returnsDistinctResults setting on the NSFetchRequest . 回答1: Functional programming approach since Swift has it, and Realm lazy loads; Not as easy/available a solution in Objective-C but for Swift at least: Swift let distinctTypes = reduce(Realm()

Grails - How to get list of distinct User Objects

匿名 (未验证) 提交于 2019-12-03 08:39:56
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there a way that, i can get list of distinct User objects(based on username). And still get result as a List of User Objects rather than, List of username's. My code is def criteria = User.createCriteria() def users = criteria.list() { projections { distinct("username") } setResultTransformer(CriteriaSpecification.ROOT_ENTITY) } return users Currently am getting List of the usernames, not User. 回答1: Ya projection is like filtering and selecting by username you should change it to def criteria = User.createCriteria() def users = criteria

Fetching distinct values on a column using Spark DataFrame

匿名 (未验证) 提交于 2019-12-03 08:36:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Using Spark 1.6.1 version I need to fetch distinct values on a column and then perform some specific transformation on top of it. The column contains more than 50 million records and can grow larger. I understand that doing a distinct.collect() will bring the call back to the driver program. Currently I am performing this task as below, is there a better approach? import sqlContext.implicits._ preProcessedData.persist(StorageLevel.MEMORY_AND_DISK_2) preProcessedData.select(ApplicationId).distinct.collect().foreach(x => { val applicationId =

Select distinct values with odata

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to create a call to odata webservice that would select only distinct values of some property. Is there any good example of how to do this? 回答1: Currently the OData protocol doesn't support the distinct operator, or any other operator which would help with such query (assuming you're looking for disctinct values of a primitive property on some entity). You should be able to workaround this by implementing a service operation on the server which performs such query on the underlying provider which usually has that ability. And then

Number of distinct sums from non-empty groupings of (possibly very large) lists

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Assume that you are given a set of coin types (maximum 20 distinct types) and from each type you have maximum 10^5 instances, such that the total number of all the coins in your list is maximum 10^6. What is the number of distinct sums you can make from non-empty groupings of these coins. for example, you are given the following lists: coins=[10, 50, 100] quantity=[1, 2, 1] which means you have 1 coin of 10, and 2 coins of 50, and 1 coin of 100. Now the output should be possibleSums(coins, quantity) = 9. Here are all the possible sums: 50 =