distinct

Duplicate rows in Oracle

依然范特西╮ 提交于 2020-01-04 13:46:32
问题 How can i prevent duplicate rows being selected in a select query? I have a table with the following fields: name type user1 user2 user3 date My query requires me to select data for a particular user only at a time which is entered by the user at front end.. Say user enters 1, then the select query should retreive data for user1 only. I am currently doing it like this: select name,type,date from table1 order by user1; But I'm getting redundant rows in the result?? what i am doing wrong? How

The method Distinct is not supported

眉间皱痕 提交于 2020-01-04 12:57:12
问题 I am using Linq to Entities and am getting this error The method Distinct is not supported On this line of code var typeIds = _context.AttributeValues.Select(av => av.AttributeTypeId).Distinct(); Why is this? 回答1: A solution is to define a WCF Data Service using (server-side) the QueryByCube method provided by my product AdaptiveLINQ (www.adaptivelinq.com). This method transforms a projection (expressed by the select operator) in an aggregation . You have just to define a cube with one

mySQL Distinct Join?

匆匆过客 提交于 2020-01-03 17:34:51
问题 I have the following database structure table_1 text_1 (INT) text_2 (INT) i18n id_i18n (PK INT) locale (PK VARCHAR(5)) text (TEXT) On table_1, the columns text_1 and text_2 are foreign keys pointing to some i18n.id_i18n entries. I can easily join the entries for a specific locale SELECT t1.text as text_1, t2.text as text_2 FROM table_1 LEFT JOIN i18n as t1 ON text_1 = t1.id_i18n and t1.locale = "en_us" LEFT JOIN i18n as t2 ON text_2 = t2.id_i18n and t2.locale = "en_us" I can also get the

mongodb: How to use an index for distinct command and query?

扶醉桌前 提交于 2020-01-03 17:26:11
问题 I have some problems with very slow distinct commands that use a query. From what I have observed the distinct command only makes use of an index if you do not specify a query : I have created a test database on my MongoDB 3.0.10 server with 1Mio objects. Each object looks as follows: { "_id" : ObjectId("56e7fb5303858265f53c0ea1"), "field1" : "field1_6", "field2" : "field2_10", "field3" : "field3_29", "field4" : "field4_64" } The numbers at the end of the field values are random 0-99. On the

Elasticsearch distinct filter values

十年热恋 提交于 2020-01-03 17:22:50
问题 I have a large document store in elasticsearch and would like to retrieve the distinct filter values for display on HTML drop-downs. An example would be something like [ { "name": "John Doe", "deparments": [ { "name": "Accounts" }, { "name": "Management" } ] }, { "name": "Jane Smith", "deparments": [ { "name": "IT" }, { "name": "Management" } ] } ] The drop-down should have a list of departments, i.e. IT, Account and Management. Would some kind person please point me in the right direction

SQL Select distinct values from multiple tables

懵懂的女人 提交于 2020-01-03 05:44:07
问题 So here's my setup I have 2 tables Old and New with the following (simplified) schemas Old [ManName] [ManNumber] New [Manager_Name] [Manager_Number] I'm looking to craft a SQL query that returns the following but in 4 columns in 1 query as opposed to 2 queries with 2 columns each select distinct manname, mannumber from OLD select distinct Manager_Name, Manager_Number from NEW So my ideal Result Set would have 4 columns: ManName ManNumber Manager_Name Manager Number Thanks! 回答1: have you tried

Get distinct values from MySQL JSON array

筅森魡賤 提交于 2020-01-02 06:36:12
问题 I got a MySQL data Table, with a JSON Column containing a list of Values: CONSTRAINT_TABLE ID | CONSTRAINT_TYPE | CONSTRAINT_VALUES ----+-----------------+-------------------------------- '2'| 'testtype' |'[801, 751, 603, 753, 803]' ...| ... | ... What I want to have is a distinct, comma-seperated List of JSON-Values. I tried it with group_concat, but it applys to the arrays, not the single values. SELECT group_concat(distinct constraint_values->>'$') FROM constraint_table c WHERE c

LINQ to Objects .Distinct() not pulling distinct objects

匆匆过客 提交于 2020-01-02 06:24:12
问题 I have two ways that I am doing a fuzzy search for a customer. One is by an abbreviated name and the other is by the customer's full name. When I take these two result sets and then union them together (which I have read several places should remove distinct values) I get duplicates. Thinking that all I need to do is then call the .Distinct() method on this, I also still get duplicates. Do I need to implement some compare functionality in my customer object? My code: Dim shortNameMatch As

SQL Server select distinct latest values

泄露秘密 提交于 2020-01-02 03:14:08
问题 I have a table that has a ton of rows (>10K). Most of the rows have duplicate role values associated with the username . What I am trying to do is select rows by distinct AND latest role added by request_id . I almost have it, but the part that is kicking my tail is there are null values in some of the request_id fields because those requests were made before that column was added. I STILL need to include them in the select statement in case a user has not entered another request since the

Loose index scan in Postgres on more than one field?

Deadly 提交于 2020-01-02 02:01:07
问题 I have several large tables in Postgres 9.2 (millions of rows) where I need to generate a unique code based on the combination of two fields, 'source' (varchar) and 'id' (int). I can do this by generating row_numbers over the result of: SELECT source,id FROM tablename GROUP BY source,id but the results can take a while to process. It has been recommended that if the fields are indexed, and there are a proportionally small number of index values (which is my case), that a loose index scan may