distinct

Select Distinct List of Words from Array with LINQ

Hi All I'm trying to get a distinct list of words from an array of words with the following code: string words = "this is a this b"; var split = words.Split(' '); IEnumerable<Word> distinctWords = (from w in split select new Word { ...

Count of Distinct Rows Without Using Subquery

Say I have Table1 which has duplicate rows (forget the fact that it has no primary key...) Is it possible to rewrite the following without using a JOIN, subquery or CTE and also without having to spell out the columns in something like a GROUP BY? SELECT COUNT(*) FROM ( SELECT DISTINCT * FROM Table1 ) T1 ...

Linq to entities : Unions + Distinct

I don't know how I can do several union with a distinct. When I use .Distinct with an IEqualityComparer an exception in threw : LINQ to Entities does not recognize the method 'System.Linq.IQueryable' My code is var union = query.Union(query1).Union(query2); union = union.Distinct(new EqualityComparerTransaction()); ...

Android: Distinct and GroupBy in ContentResolver

What would be a sensible way to add DISTINCT and/or GROUPBY to ContentResolver- based queries. Right now I have to create custom URI for each special case. Is there a better way? (I still program for 1.5 as lowest common denominator) ...

MYSQL - Using AVG() and DISTINCT together

How can you write the following in MYSQL? SELECT AVG(col1) FROM table WHERE DISTINCT col2 more info: table col1 | col2 ----------- 2 | 555.555.555.555 5 | 555.555.555.555 4 | 444.444.444.444 returns '3' Basically I'm trying to select average value of col1 where ip addresses in col2 are distinct. ...

Distinct() on Class, anonymus type and SelectListItem

I want to select all categories from a webservice. The webservice does not have a method for that, so I have to get all products, then select all categories that these products are in. When I recieve the data from the webservice, I make WebServiceProduct (ID, Name, etc) and WebServiceCategory (ID, Name, etc) objects of it. This does not...

SQL Server 2000, Get COUNT(DISTINCT ID) with a condition that I can't write to my WHERE ?

Hello all, First of all, I don't want to use a "join" because that will make my query longer and difficult to read. So what I need to do must be withing the same SELECT statement. My columns in myTable are A, B , C , D , time, ID and H H columnd tells if a record is 'Open' or 'Close', here how my query looks like. SELECT A, B, C, ...

DISTINCT a column in a database

Hi, 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 wi...

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

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 ...

MySQL Multiple Table Join

I have a 3 tables that I'm trying to join and get distinct results. CREATE TABLE `car` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (`id`) ) ENGINE=InnoDB mysql> select * from car; +----+-------+ | id | name | +----+-------+ | 1 | acura | +----+-------+ CREATE TABL...

MySQL - optimising selection across two linked tables

I have two MySQL tables, states and trans: states (200,000 entries) looks like: id (INT) - also the primary key energy (DOUBLE) [other stuff] trans (14,000,000 entries) looks like: i (INT) - a foreign key referencing states.id j (INT) - a foreign key referencing states.id A (DOUBLE) I'd like to search for all entries in trans with...

How to select a names from a column MS Excel 2007

Hey guys, I have an Excel document which has a list of students and their group names. I have another sheet within the the same excel document which is called comments. In this sheet, I would like to have a list of individual team names listed. There are 65 students and 14 defined groups. Is there a way to select the 14 group names, w...

mysql query: SELECT DISTINCT column1, GROUP BY column2

Right now I have the following query: SELECT name, COUNT(name), time, price, ip, SUM(price) FROM tablename WHERE time >= $yesterday AND time <$today GROUP BY name And what I'd like to do is add a DISTINCT by column 'ip', i.e. SELECT DISTINCT ip FROM tablename So my final output would be all the columns, from all the rows ...

MYSQL distinct query

This is my example of my table: id | name | foreign_id | 1 a 100 2 b 100 3 c 100 4 d 101 5 a 102 6 b 102 7 c 102 I would like to get the distinct file with the latest foreign_id (bigger number but not necessarily biggest). In this example, it would be row with id 4,5...

Why would I do an inner join on a non-distinct field?

I just came across a query that does an inner join on a non-distinct field. I've never seen this before and I'm a little confused about this usage. Something like: SELECT distinct all, my, stuff FROM myTable INNER JOIN myOtherTable ON myTable.nonDistinctField = myOtherTable.nonDistinctField (WHERE some filters here...) I'm not quit...

MySQL, merging 2 or more tables before execute SELECT DISTINCT query?

I want to calculate how many unique logins from 2 (or probably more tables). I tried this: SELECT count(distinct(l1.user_id)) FROM `log_1` l1 LEFT JOIN `log_2` l2 ON l1.userid = l2.userid; But it gives me result of l1. If I didnt put l1 on li.userid (distinct), it said "ambiguous". How do I combine the table, and then select uniq...

Cakephp,DISTINCT Translated results

How can I get DISTINCT translated results. My scenario is the following: I have a model named Project. One of the fields is called location. Many projects share the same location. The Question is: How can I retrieve translated DISTINCT locations. It seems like normal find with DISTINCT location does not join i18n table thus return...

PostGres Error When Using Distinct : postgres ERROR: could not identify an ordering operator for type record

** EDIT ** Nevermind, just needed to take out the parens... I get this error: ERROR: could not identify an ordering operator for type record when trying to use DISTINCT Here's the query: select DISTINCT(g.fielda, g.fieldb, r.type) from fields g LEFT JOIN types r ON g.id = r.id; And the errors: ERROR: could not identify an ord...

How to use the distinct on databases DB4O

the data like this: file1 file2 aaaa milk aaaa red bbbb box bbbb pen cccc rose i want get result like this: file1: aaaa bbbb cccc who can tell me how to do using DB4objects waiting online.... ...

Django Distinct on queryset in forms.py

Hi all, I try to get a list with distinct into the forms.py like this: forms.ModelMultipleChoiceField(queryset=Events.objects.values('hostname'), required=False).distinct() In the python shell this command works perfect, but when trying it in forms.py leaves me a blank form, so nothing appears. When i just do Events.objects.all() the ...