Re: Cross tabulations in SQL?

From: Bob Badour <bbadour_at_golden.net>
Date: Mon, 11 Aug 2003 16:22:46 -0400
Message-ID: <l_TZa.5618$Ac1.372217990_at_mantis.golden.net>


"Paul" <paul_at_not.a.chance.ie> wrote in message news:MPG.19a1e26c3f31208098970a_at_news1.eircom.net...
>
> Hi all,
>
> I have a table for a membership system with many fields, but the
> relevant ones here are Gender (M, F, U (U is from a legacy system)),
> Category (Life, Senior, Junior & Leader) and County (26 values here,
> I'll use 3 as an example - Dublin, Cork and Mayo).
>
> What I want is something like
>
> Gender by County
>
>
> | M | F | U |
> -------------------------------
> Dublin | 12 | 14 | 5 | 31
> Cork | 5 | 7 | 2 | 14
> Mayo | 6 | 6 | 3 | 15
> ---------------------------|----
> | 23 | 27 | 10 | 50
>
>
> What is the closest that I can come to doing this in SQL?

The question is: Why do you need to do this when it is logically equivalent to its current form?

> I have asked about this on a newsgroup that I frequent that deals with
> my db server of choice (Interbase Open Source) and have been told that I
> can do it in a Stored Proceedure, but even then I have to know in
> advance the number of entris in the Gender "table" for example.
>
> If it's not possible at the moment, is it not worth considering as
> functionality that should be part of a db server's capabilities?

Not really. Applications and reports are for presentation. A database management system is for data management.

> Do any servers do it at the moment?
>
> Any ideas, debates, rants, URLs, references welcome!

SAS has cross-tabs built into the language. Received on Mon Aug 11 2003 - 22:22:46 CEST

Original text of this message