aggregate

Retreive one row from 1 to many relationship between three tables

I have the following three tables : ----PRODUCT---- PRODUCT_ID DESC 1 'Pencil' 2 'Paper' ----PRICE_BY_SUPPLIER---- PRODUCT_ID SUPPLIER_ID PRICE 1 1 10 1 2 9 1 3 9.5 2 1 5 ...

NHibernate Criteria select items by the group by and sum of itemid within another table.

public class SearchText { public virtual int Id { get; set; } public virtual string Text { get; set; } } public class SearchTextLog { public virtual int Id { get; set; } public virtual SearchText SearchText { get; set; } public virtual User User { get; set; } public virtual int SearchCount { get; set; } publi...

How to 'add' a column to a query result while the query contains aggregate function?

I have a table named 'Attendance' which is used to record student attendance time in courses. This table has 4 columns, say 'id', 'course_id', 'attendance_time', and 'student_name'. An example of few records in this table is: 23    100    1/1/2010 10:00:00    Tom 24    100    1/1/2010 10:20:00    Bob 25    187    1/2/2010 08:01:01    ...

Is there a better way to aggregate a dictionary using LINQ?

I am trying to build a dictionary from an enumerable, but I need an aggregator for all potentially duplicate keys. Using ToDictionary() directly was occasionally causing duplicate keys. In this case, I have a bunch of time entries ({ DateTime Date, double Hours }), and if multiple time entries occur on the same day, I want the total ti...

How to aggregate different RSS Feed in a single Feed

Hi, i have a website (based on liferay) that produces more than 300 Feeds (one for each community). I need to expose a single Feed, but i need that feed to come from my server (that means that if my site is www.mysyte.com, the feed Must be www.mysyte.com/rss.xml). How can i do that? ...

Strategy to handle large datasets in a heavily inserted into table

I have a web application that has a MySql database with a device_status table that looks something like this... deviceid | ... various status cols ... | created This table gets inserted into many times a day (2000+ per device per day (estimated to have 100+ devices by the end of the year)) Basically this table gets a record when jus...

How to do a group by/count(*) pr year, month and day in django based on a datetime database field?

I have a table describing files with a datetime field. I want to somehow create a report that gives me the number of files grouped by each year, number of files grouped by each year and month and number of files grouped by each year, month and day. I just want records where count(*) > 0. Preferably using the ORM in django or if that`s no...

Winforms. ObjectDataSource add calculated column

Hello. I use ObjectDataSource and bind IEnumerable[Person] to my DevExpress GridView class Person { private int Id {get; set;} public string Name {get; set;} } At grid there are two columns Id,Name. I want new column "Sum", which is calculated by person object(aggragate by person). At asp.net I create new column and calculate i...

How to write this linq query to avoid too many query?

I have two table Company and Employee. And there relation is Company(one) - Employee(many). And I want to concatenate all the Employees' name to a string and output. I know I can write such a query : String names = ""; foreach(var emp in Company.Employee) { names += emp.name; } But If I use this mean, I would l...

Aggregate or join strings in linq to sql query (SQL Server)

Given a table like ID | Name | City 1 | X | Y 2 | Z | Y 3 | W | K I want to produce a result like ID | Description 1 | Y (X, Z) 3 | K (W) I tried something like From C In Clients Group C By C.ID, C.City _ Into G = Group Select New With {.ID = ID, .Description = City & _ " (" & (From C In Clients Select C.Name).Aggreg...

difficulty in creating update totals query on same table.

Consider the following table: ID nonUniqueID value total -------------------------- 1 12345 5 x 2 12345 10 x 3 789 20 x 4 789 5 x I need to make a query something like this (psuedo SQL), which will work within Access 2007: UPDATE table SET total = SUM(value) WHERE nonUniqueID IS SAM...

How can I aggregate the # of seconds in a query result?

Hi everyone, I have an Oracle 10g table that contains a # of log records. This table collects data from an environmental recording device that creates a log record every 15 seconds when it is running. I want to add all of the seconds together from the reading dates of the log file entries to ensure that the logger ran > 24 hours (84...

Aggregate a Dataset

How do i aggregate(using linq) the value of one column of a Dataset where the other column is the same. For example, my columns are Row1 Row2 2 3 4 5 6 7 2 2 6 4 7 4 2 4 I need something like this Row1 Row2 2 9 4 5 6 11 7 4 edit: the values in "Row2" are the number ...

Using SQL function as a group by field in datamapper (ruby)

I'm trying to use a slightly more interesting GROUP BY cause than what seems to be supported out of the box by DataMapper. The query I want to generate looks something like this: SELECT SUM(downloads), SUM(uploads) FROM daily_stats GROUP BY YEARWEEK(date) I'd like to be able to just tell DataMapper something along these lines: DailyS...

Vector operations by time intervals , in R ??, aggregate

Hello I have a time series (zoo with index type chron) and I need to calculate the cummax(mydata)-mydata on every day separately. Getting a zoo timeseries again. I've tried this aggregate(mydata, as.date, cummax) but aggregate can only produce a single scalar result for each subset instead of a vector. I've read that maybe with tapply...

Log4J SMTP digest/aggregate emails?

I have a JBOSS batch application that sometimes sends hundreds on emails in a minute to the same email address with Log4J errors. This causes problems with Gmail, because it says we are sending emails too quickly for that gmail account. So I was wondering if there was a way to basically create a "digest" or "aggregate" email puts all t...

Aggregates, Repositories and a service layer

Take a class which has relations with a couple of other classes. The first class can be seen as the aggregate(root). Seen from the point of the service layer how would one best split the calls? Call the repository of the aggregate for the entire object graph and call from that particular repository other repositories to handle the savi...

How does Ruby on Rails handle "Select count(*) from products group by category"?

Say if there is a table with fields Products -------- ID CategoryID Name Price ... etc How can Ruby on Rails give a table that returns select count(*) from products group by categoryID which is to show how many products in each category? How will the result be like, as opposed to Products.find(:all) which is an array of Product ...

Django: output aggregation of aggregation ordered by counts

I'm trying to output the following data in my django templates. Countries would be ordered descending by # of stories. Cities would be ordered descending by # of stories (under that country) Country A(# of stories) City A (# of stories) City B (# of stories) Country B(# of stories) City A (# of stories) City B (# of stories) ...

How do I filter dates by a cell formula in an Excel pivot table?

I am attempting to make some reports in Excel using a pivot table of a Sql server view. One of the customer requirements is to be able to filter the reports based on a date range they select, which seems reasonable. The end user process needs to be fairly simple, so my preference is to have a cell for begin date and one for end date and ...