This is a SQL problem. So it depends what kind of DB you're using. In Oracle
you could do something like this (copied from orafaq):
GROUP BY job
ORDER BY 1;
you can change it to your needs. But this doesn't help, when you have a
variabe amount of rows (in your case transX). In this case you have to write
something in PL/SQL (Oracle), plpgsql (PostgreSQL) or whatever your DB is
programmed with, or write a Python Script in Zope (not fast, but portable).
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Israel Carr
> Sent: Monday, April 17, 2006 10:17 PM
> To: email@example.com
> Subject: [Zope-DB] ZSQL
> I have a table with the columns:
> id, username, trans_type
> Sample records:
> I would like to generate output that contains the username and the
> total(count) number of each trans_type. Would also like to have a total
> of all trans_type.
> trans1 trans2 trans3 trans4
> user1 2 0 1 0
> user2 0 1 1 1
> TOTAL 2 1 2 1
> I have a ZSQL method with the following:
> select COUNT(*)
> from table
> where trans_type = <dtml-sqlvar transtype type=string>
> and username = <dtml-sqlvar username type=string>
> When testing and feeding parameters it does give me the count for one
> user and one transaction type.
> How can I create the desired output and have a general enough ZSQL
> Method that I can feed these parameters? I've been playing with some
> <dtml-in> tags and trying to call the ZSQL method but am not really sure
> how to pass parameters or if I'm way out in left field. Would I need to
> call the ZSQL method 8+ times to generate output like the table above?
> I can do pretty basic form inputs into database and selects out based on
> form or static values but this is a little more complex for me. Any
> help would be appreciated.
> Zope-DB mailing list
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.385 / Virus Database: 268.4.2/314 - Release Date: 16.04.2006
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.4.2/314 - Release Date: 16.04.2006
Zope-DB mailing list