distinct

.Distinct() clause not working c# MVC

依然范特西╮ 提交于 2019-12-11 19:18:38
问题 I need to populate a dropdown list for for a number of views. The same drop down will be used to I wrote a Html Helper method to generate the contents of the dropdown. public static List<SelectListItem> GetBatchNumbers(this HtmlHelper html) { List<SelectListItem> items = new List<SelectListItem>(); ModelContainer ctn = new ModelContainer(); var batchNumbers = ctn.SearchResults.OrderBy(x => x.BatchID).ToList(); foreach (var batch in batchNumbers.Distinct()) { items.Add(new SelectListItem() {

Get a count of the number of times distinct entries occur in database query (Android)

旧巷老猫 提交于 2019-12-11 17:51:30
问题 I have a bit of a tricky problem. My app inputs user data into the SQLite database and I have managed to write queries to get the data back out. This includes a query that gets a list of distinct values, an example may be as follows. Say you have the following data: Column a | Column b | Column c a a a a b b a b b b b b Using the 'group by' function, the query would create the following list: aaa abb bbb So what I am trying, but failing to do is expand this and get a count of the number of

Distinct & Group SQL Query

微笑、不失礼 提交于 2019-12-11 16:33:50
问题 I have a little bit complex MySQL query for me and i can't figure out how to write it without eating tons of memory. ( i don't really mind if it would ) I have the following table: TABLE: users(id,ip) ------------------------------------ 4BF1510 | 40.145.10.99 <-- SAME IP (A) SAME ID --> 510SD55 | 65.12.105.42 SAME ID --> 510SD55 | 45.184.15.10 201505V | 40.145.10.99 <-- SAME IP (A) 984AZ6C | 72.98.45.76 | 10.15.78.10 <-- SAME IP (B) | 10.15.78.10 <-- SAME IP (B) SAME ID --> B1D56SX | SAME ID

MySQL “truly distinct” join

Deadly 提交于 2019-12-11 15:09:28
问题 I've been fighting this one for a couple of hours now and struggle with the proper MySQL syntax to use. Any pointer on the kind of SQL I'm looking for will be greatly appreciated. Please consider those two simple tables: purchase: id email product_id 1 andy@aaa.com 1 2 bob@bar.com 2 3 charly@code.com 1 4 charly@code.com 2 subscriber: id email name 1 andy@aaa.com Andy 2 bob@bar.com Bob 3 charly@code.com Charly I'd like to select subscribers who did not buy product_id 1. ie: in this case, it

set column value based on distinct values in another column

笑着哭i 提交于 2019-12-11 14:06:28
问题 I am trying to do something very similar to this question: mysql - UPDATEing row based on other rows I have a table, called modset, of the following form: member year y1 y2 y3 y1y2 y2y3 y1y3 y1y2y3 a 1 0 0 0 0 0 0 0 a 2 0 0 0 0 0 0 0 a 3 0 0 0 0 0 0 0 b 1 0 0 0 0 0 0 0 b 2 0 0 0 0 0 0 0 c 1 0 0 0 0 0 0 0 c 3 0 0 0 0 0 0 0 d 2 0 0 0 0 0 0 0 Columns 3:9 are binary flags to indicate which combination of years the member has records in. So I wish the result of an SQL update to look as follows:

Set difference: find distinct members for two groups in Tableau Desktop

不羁岁月 提交于 2019-12-11 12:41:45
问题 How do I realize the following set difference/group distinction task in Tableau Desktop? I have products who have either been adjusted or not ( adjusted = 1 or adjusted= 0 ). Note that each product might be listed more than once (as the real dataset is a a matrix of stacked time series for each product). I would like to find out how many products had at least one adjustment and how many had none. This is how would do it in R: Example data: dat <- data.frame( product = c("4005808588763",

SQL - Distinct One Col, Select Multiple other?

混江龙づ霸主 提交于 2019-12-11 11:32:17
问题 I've been trying to understate the best way to write an MS SQL 2005 query which pretty much does the following... select distinct col1, col2, col3 from table1 Basically I want to perform Distinct on col1 but I dont want Dististinc on Col2/3, I just want there values. I understand its not possible to write the query this way as I think I read the Distinct is applied to the row and not the col? Could anyone please point me in the right direction? I did try right joing the values back in but

A little fuzzy on getting DISTINCT on one column?

假装没事ソ 提交于 2019-12-11 10:47:41
问题 I've seen a few different versions of this question but having difficulty applying it to what I need... MS SQL Server 2008 query: SELECT Receipts.ReceiptID, Receipts.UserID, Receipts.UserCardID, FolderLink.ReceiptFolderLinkID FROM dbo.tbl_ReceiptFolderLnk AS FolderLink INNER JOIN dbo.tbl_Receipt AS Receipts ON FolderLink.ReceiptID = Receipts.ReceiptID ** ReceiptID UserID UserCardID ReceiptFolderLinkID -------------------- -------------------- -------------------- -------------------- 1 1 3 2

Returning Distinct Dates

▼魔方 西西 提交于 2019-12-11 10:28:04
问题 Morning I am trying to return the distinct dates of an outcome by a unique identifer. For example: ID|Date 1 | 2011-10-01 23:57:59 1 | 2011-10-01 23:58:59 1 | 2010-10-01 23:59:59 2 | 2010-09-01 23:59:59 2 | 2010-09-01 23:58:29 3 | 2010-09-01 23:58:39 3 | 2010-10-01 23:59:14 3 | 2010-10-01 23:59:36 The times are not important just the dates. So for example on ID 1 I can't do a distinct on the ID as that would return only one of my dates. So I would want to return: 1|2011-10-01 1|2010-10-01 I

Mongo Age Group Aggregation

喜夏-厌秋 提交于 2019-12-11 09:47:22
问题 Please consider the collection bellow $people->insert(array("user_id" => "1", "day" => "Monday", 'age' => 18)); $people->insert(array("user_id" => "3", "day" => "Monday", 'age' => 24)); $people->insert(array("user_id" => "1", "day" => "Monday", 'age' => 18)); $people->insert(array("user_id" => "1", "day" => "Monday", 'age' => 18)); $people->insert(array("user_id" => "2", "day" => "Monday", 'age' => 25)); $people->insert(array("user_id" => "4", "day" => "Monday", 'age' => 33)); $people->insert