>I am having problems with queries again - (I need a decent book on SQL -
>any recommendations?).

I have 'ORACLE: the complete reference' which is a bit out of date but has lots
of DBA type tricks for diagnostics... Covers SQL in a very technical manner assuming
you already understand a great deal... If you've got ORACLE it's great otherwise find
another book...

>I have query that (in a simplified version) does;
>SELECT Teacher, Students, OtherStuff, Count(MaleFemale) As
>NumberOfGirls
>FROM MySchoolTable // a table listing teachers, students
>WHERE MaleFemale = 'Girl'
>GROUP BY (Teacher)

something like

SELECT
    PMST.TEACHER Teacher,
    COUNT(MMST.Student) NumberOfBoys,
    COUNT(FMST.Student) NumberOfFemales
FROM
    MySchoolTable PMST,
    MySchoolTable MMST,
    MySchoolTable FMST
WHERE
    PMST.Teacher=MMST.Teacher AND MMST.MaleFemale='MALE'
    AND
    PMST.Teacher=FMST.Teacher AND FMST.MaleFemale='FEMALE'
GROUP BY
    PMST.Teacher;

I think it'll work...

--
Aaron Scott-Boddendijk
Jump Productions
(07) 838-3371 Voice
(07) 838-3372 Fax


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to