grouping

Group List of nodes into Tree of nodes with XSL

Hi, I'm parsing a huge word file with Test descriptions, and have a problem of scope of nodes. Word basically creates a list of paragraphs and I want to group them into a parent node. So for each node 'A' I want to group all the following nodes up to the next node 'A' into 'A'. How can this be done with XSL? Example: I've gotten to : ...

Informix SQL count() comparisons

I'm trying to build a SQL query that will count both the total number of rows for each id, and the number of 'FN%' and 'W%' grades grouped by id. If those numbers are equal, then the student only has either all 'FN%' or all 'W%' or a combination of both. I need a list of all the id's who only have stats of 'FN%' or 'W%' example id # 6...

Multiple totals out of sql

I have the code below $sql = "SELECT date1, date2, userid, jobid, result, price, total, (SELECT distinct SUM(total1) FROM Jobs) as total2 FROM Jobs WHERE total ...

Parsing template schema with Python and Regular Expressions

I'm working on a script for work to extract data from an old template engine schema: [%price%] { $54.99 } [%/price%] [%model%] { WRT54G } [%/model%] [%brand%]{ LINKSYS } [%/brand%] everything within the [% %] is the key, and everything in the { } is the value. Using Python and regex, I was able to get this far: (?<=[%)(?P\w*?)(?=\%...

XSLT: Merge a set of tree hierarchies

I have an XML document based what Excel produces when saving as "XML Spreadsheet 2003 (*.xml)". The spreadsheet itself contains a header section with a hierarchy of labels: | A B C D E F G H I -+----------------------------------------------------- 1| a1 a2 2| a11 ...

Group results created at a similar timestamps

In my project I would like to select records from my database and then group them together by those that occurred at a similar time to the latest record within a certain time range. For example, with a 1 hour time range. If a user created 3 posts between 4:30pm and 5:15pm, 2 posts between 1:15pm and 1:30pm, and 1 post at 10:00am I would...

Grouping numbers for a histogram

I have a bunch of numbers I want to use to generate a histogram for a standard score. Therefore I compute the mean and the standard deviation of the numbers and normalize each x with this formula x' = (x-mean)/std_dev The result is a number between -4 and 4. I want to chart that result. I am looking for a way to group the numbers in o...

Accessing a WPF GroupItem text for conversion in a template

I'm customising the appearance of grouping in a ListBox. In ListBox.Resources, I have declared something like (formatting removed): <Style TargetType="{x:Type GroupItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type GroupItem}"> <StackPanel Orientation="Vertical"> <!-- ...

Is a GROUP BY on UNIQUE key calculates all the groups before applying LIMIT clause?

If I GROUP BY on a unique key, and apply a LIMIT clause to the query, will all the groups be calculated before the limit is applied? If I have hundred records in the table (each has a unique key), Will I have 100 records in the temporary table created (for the GROUP BY) before a LIMIT is applied? A case study why I need this: Take ...

LINQ Conditional Group

Is it possible to write a LINQ statement with a conditional group clause? Here is basically what I'm trying to do: bool someFlag = false; var result = from t in tableName group t by new { (someFlag ? 0 : t.FieldA), t.FieldB } into g select g; So basically if someFlag is set to true, I want to group only by FieldB, but if it's ...

Rails: Generating Tables based on groups of related database records

I have a collection of records in my database that I want to print out to separate tables based on the record date. So I already have the following (in Haml, fyi): %table %tr %th Name %th Type %th Total Hits - for record in @records %tr{ :class => cycle('odd','even') } %td= record.name %td= record.target...

grouping draggable objects with jquery-ui draggable

Hello, I want to use jquery draggable/droppable to let the user select a group of objects (each one has a checkbox in the corner) and then drag all the selected objects as a group... I can't figure out for the life of me how to do it haha. Here is what I'm thinking will lead to a usable solution, on each draggable object, use the star...

Rails has_many association count child rows...

What is the "rails way" to efficiently grab all rows of a parent table along with a count of the number of children each row has? I don't want to use counter_cache as I want to run these counts based on some time conditions. The cliche blog example: Table of articles. Each article has 0 or more comments. I want to be able to pull how ...

SSRS: How to make a sum that only includes the last item in a group

I have an rdlc report file, and I am trying to make a sum which can only include the last item in each group. I have a table kind of like this: Place = ? (Group header 1) User = ? (Group header 2) Date =Last(Fields!Number.Value) ...

GroupStyle sum not updated when multiple items

Hi everyone, First question here. I hope I won't mess it. Also excuse my English. I have successfully applied the trick explained here. But I still have one problem. Quick recap : I display users in a ListView. Users are regrouped by Country, and in the GroupStyle DataTemplate I display the sum of all group related Users.Total, using ...

How to get unique First Letter of names and count of names starting with that letter from SQL Server using LINQ?

Hello all. I was playing with ASP.NET MVC 1.0 a couple of days ago. I started out with a single table DB named 'Contacts', with very simple structure e.g. Title, FullName, SurName, Email, Phone, Address etc. I'm using LINQ as my Model. In my main view I wanted to display a list of alphabets that have matching FullNames starting with t...

WPF: Bind Collection with Collection to a ListBox with groups

Hi, sometimes WPF is too complex for me. I've got my "Window1" holding a collection of "Group"s. "Group" is a class with a collection of "Person"s. In the end this should be a contact list. What I simply want to do is to show the groups with its person in a ListBox, where the group name of the list groups equals the Name Property of my ...

Grouping by week/month/etc & ActiveRecord?

I'm doing some statics calculation in my product. A user has performed a number of operations, let's say posted comments. I want to be able to show them how many comments they've posted per week for the past month, or per month for the past year. Is there any way with activerecord to group this way? Is my best best to simply do thi...

Are groups in Linq to Sql already sorted by Count() descending?

It appears so, but I can't find any definitive documentation on the subject. What I'm asking is if the result of this query: from x in Db.Items join y in Db.Sales on x.Id equals y.ItemId group x by x.Id into g orderby g.Count() descending select g.First() is ALWAYS THE SAME as the following query: from x in Db.Items join y in Db.Sal...

MySQL - show field value only in first instance of each grouped value?

I don't think this is possible, but I would like to be proved otherwise. I have written a simple report viewing class to output the results of various database queries. For the purpose of improving the display, when I have a report with grouped data, I would like to display the field value only on the first row of each unique value - an...