aggregate-functions

Aggregate Function in LINQ expression throws error. (cannot be translated into a store expression.)

白昼怎懂夜的黑 提交于 2019-12-01 18:49:39
Error: LINQ to Entities does not recognize the method 'System.String Aggregate[String,String](System.Collections.Generic.IEnumerable 1[System.String], System.String, System.Func 3[System.String,System.String,System.String])' method, and this method cannot be translated into a store expression. Linq Expression: Items = context.TESTANSWER.Where(x => x.ID == 6729223232) .Join(context.QUESTIONREPOs, x => x.QUESTIONID, y => y.ID, (x, y) => new { x = x, y = y }) .Join(context.OPTIONREPOs, p => p.x.QUESTIONID, q => q.QUESTIONID, (p, q) => new { p = p, q = q }).Where(p => p.p.x.RESPONSEID == p.q.ID)

SPARQL - How do you use count?

让人想犯罪 __ 提交于 2019-12-01 18:40:33
I have this query SELECT ?s WHERE {?a <http://xmlns.com/foaf/0.1/topic_interest> ?s} which returns aaa aaa aaa bbb bbb ccc However, I want to display it as aaa | 3 bbb | 2 ccc | 1 I am using dotnetrdf. This is what i tried SELECT (COUNT(*) AS ?s) WHERE {?a <http://xmlns.com/foaf/0.1/topic_interest> ?s} and this just gives me the number of rows there are which is 3080. Can you tell me how to make it right? Thanks This is because COUNT(*) simply counts result rows for each group If there is no GROUP BY clause in your query then there is one implicit group of all results hence you just get the

Get count of foreign key from multiple tables

纵然是瞬间 提交于 2019-12-01 17:59:11
问题 I have 3 tables, with Table B & C referencing Table A via Foreign Key. I want to write a query in PostgreSQL to get all ids from A and also their total occurrences from B & C. a | b | c ----------------------------------- id | txt | id | a_id | id | a_id ---+---- | ---+----- | ---+------ 1 | a | 1 | 1 | 1 | 3 2 | b | 2 | 1 | 2 | 4 3 | c | 3 | 3 | 3 | 4 4 | d | 4 | 4 | 4 | 4 Output desired (just the id from A & total count in B & C) : id | Count ---+------- 1 | 2 -- twice in B 2 | 0 -- occurs

Aggregate Function in LINQ expression throws error. (cannot be translated into a store expression.)

巧了我就是萌 提交于 2019-12-01 17:44:40
问题 Error: LINQ to Entities does not recognize the method 'System.String Aggregate[String,String](System.Collections.Generic.IEnumerable 1[System.String], System.String, System.Func 3[System.String,System.String,System.String])' method, and this method cannot be translated into a store expression. Linq Expression: Items = context.TESTANSWER.Where(x => x.ID == 6729223232) .Join(context.QUESTIONREPOs, x => x.QUESTIONID, y => y.ID, (x, y) => new { x = x, y = y }) .Join(context.OPTIONREPOs, p => p.x

PostgreSQL equivalent for MySQL GROUP BY

。_饼干妹妹 提交于 2019-12-01 17:29:57
I need to find duplicates in a table. In MySQL I simply write: SELECT *,count(id) count FROM `MY_TABLE` GROUP BY SOME_COLUMN ORDER BY count DESC This query nicely: Finds duplicates based on SOME_COLUMN, giving its repetition count. Sorts in desc order of repetition, which is useful to quickly scan major dups. Chooses a random value for all remaining columns, giving me an idea of values in those columns. Similar query in Postgres greets me with an error: column "MY_TABLE.SOME_COLUMN" must appear in the GROUP BY clause or be used in an aggregate function What is the Postgres equivalent of this

Aggregate data to weekly level with every week starting from Monday

主宰稳场 提交于 2019-12-01 17:12:29
I have a data frame like, 2015-01-30 1 Fri 2015-01-30 2 Sat 2015-02-01 3 Sun 2015-02-02 1 Mon 2015-02-03 1 Tue 2015-02-04 1 Wed 2015-02-05 1 Thu 2015-02-06 1 Fri 2015-02-07 1 Sat 2015-02-08 1 Sun I want to aggregaate it to weekly level such that every week starts from "monday" and ends in "sunday". So, in the aggregated data for above, first week should end on 2015-02-01. output should look like something for above firstweek 6 secondweek 7 I tried this, data <- as.xts(data$value,order.by=as.Date(data$interval)) weekly <- apply.weekly(data,sum) But here in the final result, every week is

PostgreSQL equivalent for MySQL GROUP BY

被刻印的时光 ゝ 提交于 2019-12-01 16:49:40
问题 I need to find duplicates in a table. In MySQL I simply write: SELECT *,count(id) count FROM `MY_TABLE` GROUP BY SOME_COLUMN ORDER BY count DESC This query nicely: Finds duplicates based on SOME_COLUMN, giving its repetition count. Sorts in desc order of repetition, which is useful to quickly scan major dups. Chooses a random value for all remaining columns, giving me an idea of values in those columns. Similar query in Postgres greets me with an error: column "MY_TABLE.SOME_COLUMN" must

Aggregate data to weekly level with every week starting from Monday

删除回忆录丶 提交于 2019-12-01 16:27:04
问题 I have a data frame like, 2015-01-30 1 Fri 2015-01-30 2 Sat 2015-02-01 3 Sun 2015-02-02 1 Mon 2015-02-03 1 Tue 2015-02-04 1 Wed 2015-02-05 1 Thu 2015-02-06 1 Fri 2015-02-07 1 Sat 2015-02-08 1 Sun I want to aggregaate it to weekly level such that every week starts from "monday" and ends in "sunday". So, in the aggregated data for above, first week should end on 2015-02-01. output should look like something for above firstweek 6 secondweek 7 I tried this, data <- as.xts(data$value,order.by=as

Selecting an average of records grouped by 5 minute periods

故事扮演 提交于 2019-12-01 13:16:39
I'm having a slight issue. I have a PostgreSQL table with such format time (datetime) | players (int) | servers (int) --------------------------------------------------- 2013-12-06 13:40:01 | 80 | 20 2013-12-06 13:41:13 | 78 | 21 etc. I would like to group them by 5 minute periods and get an average of the group as a single value, so there will be 20% of the records, each containing an average of ~5 numbers, with time set to the first time value in the group. I have no idea how to do this in PgSQL. So the result would be: 2013-12-06 13:40:01 | avg of players on :40, :41, :42, :43, :44 | same

mysql: select the last 10 messages and for each message the last 3 replies

纵然是瞬间 提交于 2019-12-01 12:58:26
For simplicity lets strip down the messages table to its minimum, with some sample data message_id reply_to createdate 1 0 123 2 0 124 3 0 123 4 1 154 5 1 165 the reply_to is the message_id wich the message is a reply to so im looking for a sql-statement/procedure/function/other table design that lets me select the last 10 messages and for each of those the last 3 replies, i dont mind changing the table structure or even keeping some sort of a record for the last 3 replies just selecting the last 10 messages is SELECT * FROM message ORDER BY createdate LIMIT 10; and for each of those messages