Hi. I just started checking out SQLAlchemy and it looks pretty neat. I like the idea of a clean OO interface that builds SQL under the hood.
What I'm particularly hoping is that SQLAlchemy might be helpful for something I often want to do that's painful when writing SQL queries by hand. What I often want is to get query results where different columns aggregate along different dimensions. So, just to make up an example, let's say I have a table with columns Firstname, Lastname, and Income. What I'd like is to get query results where the columns are Firstname, Lastname, Income, "sum of incomes of everyone with this Firstname", "sum of incomces of everyone with this Lastname". I'm using SQL to store some research data, and I like to be able to browse the data interactively. This is painful using direct SQL queries. The sticking point with situations like the above is that I want one column to sum grouping by Firstname, and another column to sum grouping by Lastname, and I want to do these sums without collapsing their associated groups.. I'm a relative novice with SQL, but as far as I know this requires joining the table to itself and querying the different groupings separately from the two versions. This quickly becomes unwieldly when I have more than two aggregate columns, because if I want N different aggregate dimensions, I have to join the table to itself N times. Does SQLAlchemy have the smarts to allow me to somehow specify "group by" information on a per-column basis, and then under the hood generate the joins necessary to retrieve the aggregates I want? If so, how can I do this? Or even if I had to write the joins, but could do so in some more compact way than is possible in raw SQL. Anything that's simpler than manually writing out all the joins would be an improvement over what I'm doing now. Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---
