distinct

XQuery distinct values with where clause problem

末鹿安然 提交于 2019-12-08 01:37:11
问题 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<

Create MySQL view using distinct values as columns

吃可爱长大的小学妹 提交于 2019-12-07 23:44:43
问题 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

Group by clause vs. Distinct() [closed]

南楼画角 提交于 2019-12-07 18:01:31
问题 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

Select distinct entities by specific column

与世无争的帅哥 提交于 2019-12-07 15:56:00
问题 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

SELECT DISTINCT values after a JOIN

孤街醉人 提交于 2019-12-07 12:23:08
问题 I have 3 tables: Vehicle: vehicle_id, vehicle_type 1, motorcycle 2, car 3, van Owners: person_id, vehicle_id, date_bought 1, 1, 2009 1, 2, 2008 2, 3, 2009 2, 1, 2005 I want to display a list of all vehicle names. If the person_id = 1 , date_bought should also be returned. So I thought I would start with this: SELECT * FROM vehicles LEFT JOIN Owners USING (vehicle_id) which returns this: 1, 1, motorcycle, 2009 1, 2, car, 2008 2, 3, van, 2009 2, 1, motorcycle, 2005 However, I now cannot narrow

Distinct values with XSLT 1.0 when XPath has multiple criteria

核能气质少年 提交于 2019-12-07 10:53:06
问题 Yet another question about getting distinct values using XSLT 1.0. Here's a stupid, made-up example that should illustrate my problem. <?xml version="1.0" encoding="UTF-8"?> <moviesByYear> <year1994> <movie> <genre>Action</genre> <director>A</director> </movie> </year1994> <year1994> <movie> <genre>Comedy</genre> <director>A</director> </movie> </year1994> <year1994> <movie> <genre>Drama</genre> <director>B</director> </movie> </year1994> <year1994> <movie> <genre>Thriller</genre> <director>C

Rails 3.1 distinct find and missing attributes

风流意气都作罢 提交于 2019-12-07 09:16:18
问题 class State < ActiveRecord::Base has_many :cities end class City < ActiveRecord::Base belongs_to :state has_many :companies end class Company < ActiveRecord::Base belongs_to :city end I'm trying to list all states, and their respective cities, that contain at least one company registered. My first try was the following query: states = State.joins(:cities => :companies).includes(:cities) Which works, but I end up getting duplicates if a state has more than one city with companies in it. I then

NHibernate: Get distinct results based on a column, but retrieve all columns

Deadly 提交于 2019-12-07 04:20:35
问题 I have a table GL that contains GLCode. I need to get a list of unique GLCodes, but get all the other columns. The following SQL produces the results I want. select * from GL where GLId in (select Min(GLId) from GL group by GLCode ) Is there a way to do this using the Criteria API? This is my best attempt: var subQuery = DetachedCriteria.For<GL>(); subQuery .SetProjection(Projections.Property("GLCode")) .SetResultTransformer(new DistinctRootEntityResultTransformer()); return (List<GL>

Finding distinct values of non Primary Key column in CQL Cassandra

旧时模样 提交于 2019-12-07 01:24:34
问题 I use the following code for creating table: CREATE KEYSPACE mykeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }; USE mykeyspace; CREATE TABLE users ( user_id int PRIMARY KEY, fname text, lname text ); INSERT INTO users (user_id, fname, lname) VALUES (1745, 'john', 'smith'); INSERT INTO users (user_id, fname, lname) VALUES (1744, 'john', 'doe'); INSERT INTO users (user_id, fname, lname) VALUES (1746, 'john', 'smith'); I would like to find the distinct value

数据倾斜的原因和解决方案

荒凉一梦 提交于 2019-12-06 23:45:38
MapReduce简介 MapReduce是面向大数据并行处理的计算模型、框架和平台,它隐含了以下三层含义: 1)MapReduce是一个基于集群的高性能并行计算平台(Cluster Infrastructure)。它允许用市场上普通的商用服务器构成一个包含数十、数百至数千个节点的分布和并行计算集群。 2)MapReduce是一个并行计算与运行软件框架(Software Framework)。它提供了一个庞大但设计精良的并行计算软件框架,能自动完成计算任务的并行化处理,自动划分计算数据和计算任务,在集群节点上自动分配和执行任务以及收集计算结果,将数据分布存储、数据通信、容错处理等并行计算涉及到的很多系统底层的复杂细节交由系统负责处理,大大减少了软件开发人员的负担。 3)MapReduce是一个并行程序设计模型与方法(Programming Model & Methodology)。它借助于函数式程序设计语言Lisp的设计思想,提供了一种简便的并行程序设计方法,用Map和Reduce两个函数编程实现基本的并行计算任务,提供了抽象的操作和并行编程接口,以简单方便地完成大规模数据的编程和计算处理。 什么是数据倾斜及数据倾斜是怎么产生 简单来说数据倾斜就是数据的key 的分化严重不均,造成一部分数据很多,一部分数据很少的局面。 举个 word count 的入门例子,它的map