grouping

Regular Expression Fill-Down

I have a plain text file something like this: Ford\tTaurus F-150 F-250 Toyota\tCamry Corsica In other words, a two-level hierarchy where the first child is on the same line as the parent, but subsequent children on lines following, distinguished from being a parent by a two-space prefix (\t above represents a literal tab in the ...

PHP splitting arrays into groups based on one field's value

I have an array containing arrays of names and other details, in alphabetical order. Each array includes the first letter associated with the name. Array ( [0] => Array ( [0] => a [1] => Alanis Morissette ) [1] => Array ( [0] => a [1] => Alesha Dixon ...

regex return conditional group

Hi , I spent lot time figuring out a simple regex to return a group (only 1st group). So the string can be - "No purchase required" or "Purchase of $50.00 worth groceries is required." I am trying to write a regex which can parse "No" or "50" based on the given string. This is what I have written. (?:(No) monthly maintenance|Purchas...

MySQL SELECT statement that groups results by id?

Hi all, I am trying to create a MySQL SELECT statement that will select a bunch of rows from a table and will group the results by the id of the row (multiple rows will have the same id). Here's an example of what I'm trying to do. Let's say I have the following table: id | name 1 | Art 1 | Arnold 1 | ...

How to select the first row for each group in MySQL?

In C# it would be like this: table .GroupBy(row => row.SomeColumn) .Select(group => group .OrderBy(row => row.AnotherColumn) .First() ) Linq-To-Sql translates it to the following T-SQL code: SELECT [t3].[AnotherColumn], [t3].[SomeColumn] FROM ( SELECT [t0].[SomeColumn] FROM [Table] AS [t0] GROUP BY ...

How do I show all group headers in Access 2007 reports?

This is a question about Reports in Access 2007. I'm unsure whether the solution will involve any programming, but hopefully someone will be able to help me. I have a report which lists all records from a particular table (call it A), and groups them by their associated record in a related table (call it B). I use the 'group headers' to...

Grouping in datagrid - rows not getting displayed

Hello, I have to group the data int the datagrid. I have done following for that: Have added the style to resources as: > <Style x:Key="GroupHeaderStyle" > TargetType="{x:Type GroupItem}"> > <Setter Property="Template"> > <Setter.Value> > <ControlTemplate TargetType="{x:Type GroupItem}"> > ...

Linq-to-SQL Grouping not ordering correctly

Hi can someone help me convert this tsql statement into c# linq2sql? select [series] from table group by [series] order by max([date]) desc This is what i have so far - the list is not in correct order.. var x = from c in db.Table orderby c.Date descending group c by c.Series into ...

change header for every group in datagrid wpf

hello, I have a datagrid in which I have grouped the rows according to the author. I have bound the datagrid with collection of Author class objects. where, Author class have three properties as Book, Publication and Number of copies which would correspond to the columns in the group in datagrid. My problem is I want to display the su...

IGrouping and Casting in Linq

I have the following query: var groupCats = from g in groups group g by g.Value into grouped select new { GroupCategory = grouped.Key, Categories = GetCategories(grouped.Key, child) }; This works fine. In the anonymous type returned GroupCateg...

Calculate differences between rows while grouping with SQL

I have a postgresql table containing movements of different items (models) between warehouses. For example, the following record means that 5 units of model 1 have been sent form warehouse 1 to 2: source target model units ------ ------ ----- ----- 1 2 1 5 I am trying to build a SQL query to obtain the difference be...

Combinatorics grouping problem

I'm looking for an algorithm in c# that solves a combinatorics problem: Assume i have the objects 1,2,3,4 I want to get all possible ways to group these object in multiple groups, that each time contain all objects. Order is not important. Example: <1,2,3,4> <1,2 / 3,4> <1,3 / 2,4> <1,4 / 3,2> <1,2,3 / 4> <1,2,4 / 3> <1,3,4 / 2> <2...

WPF - Custom sorting logic for groups using CollectionViewSource

I have a list of "stuff" which needs to be filtered then displayed in a grouped and sorted manner. The data needed to calculate the grouping and sorting order is not available as simple properties - there needs to be some work done in code to calculate the order and groups. CollectionViewSource lets me define custom filter and sort logi...

Linq to Sql GroupJoin Paging oddity

I have noticed a strange Sql Translation in a LinqToSql Query I was trying to optimise. If I execute the following Recipients.GroupJoin( RecipientAttributes, x => x.Recipient_Id, y => y.Recipient_Id, (x,y) => new {Recipient = x, Attributes = y}) .Skip(1) .Take(1000) It executes in a single q...

GroupBy Count With Subsonic 3

Hi, I like to perform the following with SubSonic 3 without using Linq (using dynamic lookup of columns and tables). Also, no inline sql (to prevent sql-injections). http://www.java2s.com/Code/SQL/Select-Clause/COUNTandGROUPBY.htm mysql> SELECT species, COUNT(*) FROM Bird GROUP BY species; +---------+----------+ | species | COUNT(*) | ...

SQL - sub count

Hi I've got some SQL ... SELECT AdviceNo, Registration FROM tblSalesDetail that produces something like ... ADV00001, ABC123 ADV00001, CDE564 ADV00002, FGE432 ADV00003, HUY789 ADV00003, MJS532 ADV00003, JFY428 Can anyone tell me how I'd adjust it to see the following please? ADV00001, ABC123, 1 ADV00001, CDE564, 2 ADV00...

Organizing a random list of objects in Python.

So I have a list that I want to convert to a list that contains a list for each group of objects. ie ['objA.attr1', 'objC', 'objA.attr55', 'objB.attr4'] would return [['objA.attr1', 'objA.attr55'], ['objC'], ['objB.attr4']] currently this is what I use: givenList = ['a.attr1', 'b', 'a.attr55', 'c.attr4'] trgList = [] objNames = [] ...

Grouping php array items based on user and created time

This is an array of objects showing a user uploading photos: Array ( [12] => stdClass Object ( [type] => photo [created] => 2010-05-14 23:36:41 [user] => stdClass Object ( [id] => 760 [username] => mrsmith ) ...

Use Linq to SQL to generate sales report

I currently have the following code to generate a sales report over the last 30 days. I'd like to know if it would be possible to use linq to generate this report in one step instead of the rather basic loop I have here. For my requirement, every day needs to return a value to me so if there are no sales for any day then a 0 is returned...

Can't find my bug: Group flat data in Advanced Datagrid w'ont work

Hi, i've got an ArrayCollection which is properly displayed in this Advanced Datagrid: <mx:AdvancedDataGrid id="drawingDataDG" editable="true" sortableColumns="true" headerWordWrap="true" sortExpertMode="true" rowCount="8" y="10" right="10" left="10" dataProvider="{model.drawingsData}"> <mx:columns> <mx:Advanced...