You could do something like: retrieve (a.dept, x=sum(a.total by a.dept) / sum(a.total));
if I remember correctly. --------------------------------------------------------------------------- Vincent Hikida wrote: > > ----- Original Message ----- > From: "Bruce Momjian" <[EMAIL PROTECTED]> > To: "elein" <[EMAIL PROTECTED]> > Cc: "Jan Wieck" <[EMAIL PROTECTED]>; "Vincent Hikida" > <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > Sent: Thursday, July 24, 2003 5:35 PM > Subject: Re: Fw: [GENERAL] Is SQL silly as an RDBMS<->app interface? > > > > > > Yes, it was more powerful because you could do aggregates in the query > > independent of the results returned by the query. > > > > The 'by' feature of aggregates always confused me because it would > > modify the aggregate WHERE clause (that was independent of the outer > > query) and restrict the aggregate to only process rows where the outer > > query's column value matched the same column's value in the aggregate. > > > > Actually, I used a hierarchical/relational DBMS called Nomad in 1981. If I > understand Bruce, Nomad could do the same thing. I could aggregate at > different levels in the same query. Each aggregate created a break and I > could add whatever code I wanted at the level. I could also refer to any > level of aggregate in the rest of the query. I could also refer to any level > aggregate in the rest of the code. This meant that I could for example > calculate what percentage of the total the individual row was. The only > problem was that I could only join two tables at a time so if I wanted to > join several tables I had to have several statements. Each statement created > an intermediate table which was easy to refer to in subsequent statements. > > Vincent > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to [EMAIL PROTECTED] so that your > message can get through to the mailing list cleanly > -- Bruce Momjian | http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 ---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend