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
{
...
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
...
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());
...
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)
...
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.
...
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...
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, ...
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...
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
...
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...
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...
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...
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 ...
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...
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...
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...
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...
** 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...
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....
...
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 ...