grouping

LINQ Product of two fields in aggregated query

Hi, I need to calculate a sum of product of two fields. This will be used for average weighted price. avgPrice = sum( price*volume) / sum(volume). Both price1 and price2 return error "Specified cast is not valid." var result3 = from sym in dataTableAsEnumerable() group sym by new { symbol = sym["symbol"] } into ...

How to map a group entity class from a "group name" column in NHibernate?

I have a table in my database looking roughly like this: create table Foo ( Id int identity not null, Name varchar(100) not null, GroupName varchar(100) not null, constraint PK_Foo primary key (Id) ) Now I want to map this table into two entity classes like this: class Foo ...

How do I group by a property in an object collection using LINQ?

Hi, I have a collection of objects as Dim XXX As IEnumerable(Of MyObject) which has been populated. There is a property in MyObject that I want to group by, for example MyObject.MyCode. Looking through the LINQ examples it is not clear what the Group XX By INTO syntax is doing and I can't understand it. So what I'm after is the abilit...

jsp: Grouping news by month

Hey guys. I have a question: I now have a sort array where I have all the news that I fetch from the database. But now ALL are shown. What I want are the news from the last 3 months and these news grouped by month. september ......... News 1, News 2 News 3, News 4 august ....... . . . Any ideas? ...

WPF DataGrid Virtualization with Grouping

I'm using the WPF DataGrid from CodePlex and I need to get Virtualization to work with grouping. This question is on topic and points to an MSDN Example but it only covers ListControls with with simple (i.e. single 'column') DataTemplates. Grouping and Virtualization seems like a pretty common use case for a Grid. Is there a standard...

MS Access. Editable Selection. Grouping of Items based on data other than primary key.

I hope I can explain this clearly. I have a table, lets call it Widgets, that contains information (Color, Size, etc) about many many different widgets that are specified by an ID# which is the primary key. I also have a table, call it Tests, that is related to Widgets through a one to many relationship. Each row in this table represen...

Interactive Sorting on Top Group's aggregate data in SQL Reporting 2005

I have a report that has a group row that shows a group name and sum details in certain columns. Then a details row within the group. I show the detail rows hidden to begin with and an expansion button. That part works. I also want to be able to sort on the group's aggregate data, not detail data. So when the detail rows are hidden, some...

How to access grouped values returned by a linq query

I've got the following code: List<Person> people = new List<Person> { new Person{ Id = 1, Name = "Bob"}, new Person{ Id = 2, Name = "Joe"}, new Person{ Id = 3, Name = "Bob"} }; var peopleGroupedByName = from p in people group p by p.Name; //get all groups where the number o...

[Flex] find and expand grouping field by string?

Hello, i'm just to find a way how i can find a grouping field by string in my ADG for expanding this group. after my data is loaded and displayed in collapsed groups in my ADG i need to look up for a certain group field. if the GroupingCollection contains the field i need to expand only this group. if no group field matches all groups ...

WPF items not visible when grouping is applied

Hi, I'm having this strange issue with my ItemsControl grouping. I have the following setup: <ItemsControl Margin="3" ItemsSource="{Binding Communications.View}" > <ItemsControl.GroupStyle> <GroupStyle> <GroupStyle.ContainerStyle> <Style TargetType="{x:Type GroupItem}"> <Sette...

(SQL) Grouping by End of week

I have a report which needs to total up the number of registrations per week, over the last ten weeks and display it as "Week Ending October 10th, 2009" 500" "Week Ending OCtober 3rd, 2009" 400" "Week Ending September 26, 2009" 1000" etc... Here is my query: SELECT Count(*) as [Total] ,Week = DateAdd(day, -1 * da...

Blank groups in Jasper Reports

I'm using Jasper Reports to generate reports from Hibernate model instances. To do this I'm passing the data using a JRBeanCollectionDataSource. Each model instance has a "sequence" number, the report is grouped by this number. My problem is that I need to print a message like "There are no items with this sequence number" if there is a...

Table of averages by date for multiple IDs

I have a table full of items that each have a unique ItemID. There is another table with information on tests that are done on these items around once a month (some may have multiple tests per month and some may have none some months) and each test entry has a full date mm/dd/yyyy. I would like to display the average of one of the fiel...

Is there a better Regex for parsing DTD

I've got the DTD for OFX 1.03 (their latest version despite having developed and released 1.60, but I digress...) I would like to use regex to have groups that split an entity, element, other tags into its parts for further processing such that I would take a tag like this: <!ENTITY % ACCTTOMACRO "(BANKACCTTO | CCACCTTO | INVACCTTO)"> ...

Nested grouping in ListView

Is it possible to define few groups in one ListView? I mean group inside group, it is like tree. If yes - any link to sample, tutorials. ...

Help mysql grouping

Please help me figure a single query that will transform the data below... |id |status_a |status_b | |+++++++++++++++++++++++| | 1|active |inactive | ...into this one. |status_group |count| |++++++++++++++++++++++++| |status_a.active | 1| |status_b.inactive | 1| edit: If a single pass query is possible then that wil...

Shortening GROUP BY Clause

Is it possible to shorten a group by clause so that you do not have to repeat the fields mentioned in the select clause ad nauseam? For example: SELECT field1, field2, field3, field4 FROM table GROUP BY field1, field2, field3, field4 to: SELECT field1, field2, field3, field4 FROM table GROUP BY SELECT.* ...

C# - Multiple groupings

I have an IList<SomeObject> where SomeObject has properties for Date (DateTime) and SomeEnum. I've been trying, first with extension functions then with for loops to group first day, they by the value of the enum. I need the output as SomeObjectGroup objects, where the groups have properties for Date, the enum value and a List<SOmeObject...

Possible to group by Count in LINQ?

This might be either impossible or so obvious I keep passing over it. I have a list of objects(let's say ints for this example): List<int> list = new List<int>() { 1, 2, 3, 4, 5, 6 }; I'd like to be able to group by pairs with no regard to order or any other comparison, returning a new IGrouping object. ie, list.GroupBy(i => someLo...

Crystal Reports: including a subreport into a grouping section?

I have a report which lists out a company detail. There are two sections to the company detail. The first portion lists out environmental data and the second is actually a subreport which lists out Cash flow details for every single year of the company. I have multiple companies i need to do this for--so i grouped the report by Company...