aggregation

MYSQL count of count?

百般思念 提交于 2019-11-27 06:21:20
问题 I have a mysql table like: id, visitorid, pageid When a visitor hits the website it stores their visitor id and the page id as a row. I am trying to extract the number of visitors who hit the website exactly X times. (for a chart). so how many visit just one page, how many visit 2 pages... so far I have: SELECT COUNT(visid),visid FROM vislog GROUP BY visid ORDER BY COUNT(visid) DESC But I don't know how to do the next part of counting the counts. Is it possible to do as a mysql query? Edit: I

MySQL - Using COUNT(*) in the WHERE clause

佐手、 提交于 2019-11-27 06:14:43
I am trying to accomplish the following in MySQL (see pseudo code) SELECT DISTINCT gid FROM `gd` WHERE COUNT(*) > 10 ORDER BY lastupdated DESC Is there a way to do this without using a (SELECT...) in the WHERE clause because that would seem like a waste of resources. try this; select gid from `gd` group by gid having count(*) > 10 order by lastupdated desc I'm not sure about what you're trying to do... maybe something like SELECT gid, COUNT(*) AS num FROM gd GROUP BY gid HAVING num > 10 ORDER BY lastupdated DESC SELECT COUNT(*) FROM `gd` GROUP BY gid HAVING COUNT(gid) > 10 ORDER BY lastupdated

Aggregation vs Composition vs Association vs Direct Association

别说谁变了你拦得住时间么 提交于 2019-11-27 04:57:33
问题 I am reviewing my knowledge in object-oriented programming. Under the relationship between classes topic, I have encountered some relationships which are a bit ambiguous to me. I know dependency "uses-a" and inheritance "is-a" but I'm a bit unfamiliar with Aggregation, Composition, Association and Direct Association; also, which of them is "has-a" relationship. Some use Aggregation interchangeably with Association. What is Direct Association? Also, what is Composition? In UML diagrams, the

Fill missing dates in records

纵然是瞬间 提交于 2019-11-27 04:43:36
问题 I have a collection of ProductViews . ProductView { productId: '5b8c0f3204a10228b00a1745, createdAt: '2018-09-07T17:18:40.759Z', } And I have a query for fetching the daily views for a specific product. Query ProductView.aggregate([ { $match: { productId } }, { $project: { day: { $substr: ["$createdAt", 0, 10] } } }, { $group: { _id: "$day", count: { $sum: 1 }, time: { $avg: "$createdAt" }, } }, { $sort: { _id: 1 } }, { $project: { date: '$_id', views: '$count', }, }, ]).exec((err, result) =>

R Dynamically build “list” in data.table (or ddply)

戏子无情 提交于 2019-11-27 03:19:37
问题 My aggregation needs vary among columns / data.frames. I would like to pass the "list" argument to the data.table dynamically. As a minimal example: require(data.table) type <- c(rep("hello", 3), rep("bye", 3), rep("ok",3)) a <- (rep(1:3, 3)) b <- runif(9) c <- runif(9) df <- data.frame(cbind(type, a, b, c), stringsAsFactors=F) DT <-data.table(df) This call: DT[, list(suma = sum(as.numeric(a)), meanb = mean(as.numeric(b)), minc = min(as.numeric(c))), by= type] will have result similar to this

Limit ElasticSearch aggregation to top n query results

蹲街弑〆低调 提交于 2019-11-27 02:42:28
问题 I have a set of 2.8 million docs with sets of tags that I'm querying with ElasticSearch, but many of these docs can be grouped together by one ID. I want to query my data using the tags, and then aggregate them by the ID that repeats. Often my search results have tens of thousands of documents, but I only want to aggregate the top 100 results of the search. How can I constrain an aggregation to only the top 100 results from a query? 回答1: Sampler Aggregation : A filtering aggregation used to

Is there an aggregateBy method in the stream Java 8 api?

不羁岁月 提交于 2019-11-27 01:53:57
问题 Run across this very interesting but one year old presentation by Brian Goetz - in the slide linked he presents an aggregateBy() method supposedly in the Stream API, which is supposed to aggregate the elements of a list (?) to a map (given a default initial value and a method manipulating the value (for duplicate keys also) - see next slide in the presentation). Apparently there is no such method in the Stream API. Is there another method that does something analogous in Java 8 ? 回答1: The

UML aggregation vs association

懵懂的女人 提交于 2019-11-26 21:51:14
Here I am, with another question about aggregation and association. I wanted to learn some basics of UML, so I started reading "UML distilled" by Martin Fowler. I read both chapters about classes, and there is one thing that I can't fully grasp I think, and that is aggregation vs association. In the book there is this quote: In the pre-UML days, people were usually rather vague on what was aggregation and what was association. Whether vague or not, they were always inconsistent with everyone else. As a result, many modelers think that aggregation is important, although for different reasons.

calling constructor of a class member in constructor

回眸只為那壹抹淺笑 提交于 2019-11-26 20:09:43
问题 Can I call constructor of a member in my Class's constructor? let say If I have a member bar of class type foo in my class MClass . Can I call constructor of bar in MClass's constructor? If not, then how can I initialize my member bar? It is a problem of initializing members in composition(aggregation). 回答1: Yes, certainly you can! That's what the constructor initializer list is for. This is an essential feature that you require to initialize members that don't have default constructors, as

Why are Spark Parquet files for an aggregate larger than the original?

僤鯓⒐⒋嵵緔 提交于 2019-11-26 14:31:55
问题 I am trying to create an aggregate file for end users to utilize to avoid having them process multiple sources with much larger files. To do that I: A) iterate through all source folders, stripping out 12 fields that are most commonly requested, spinning out parquet files in a new location where these results are co-located. B) I try to go back through the files created in step A and re-aggregate them by grouping by the 12 fields to reduce it to a summary row for each unique combination. What