home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.databases.ingres
- Path: sparky!uunet!darwin.sura.net!uvaarpa!cv3.cv.nrao.edu!mail-to-news-gateway
- From: Stephan Ozminski <OZMINSKI%MSUKBS.BITNET@pucc.Princeton.EDU>
- Subject: Q: nested group by
- Message-ID: <01GMLK295O0GA3CNUC@MSUKBS.BITNET>
- Sender: daemon@nrao.edu
- Organization: National Radio Astronomy Observatory
- Date: Mon, 20 Jul 1992 14:33:00 GMT
- Lines: 47
-
- Does anyone know about the following bug? I ask on the net because we
- do not have Technical Support, only Update Support, so I am not likely
- get a response if I sent them a message directly. So, I'm posting to
- the net without first asking Ingres.
-
- It is possible for Ingres (SunOS v6.3 and v6.4/01) to return incorrect
- results if a view with a group by clause references a view with a
- group by clause, even though relational theory would dictate
- otherwise.
-
- Nested group by clauses are necessary because Ingres SQL does not
- support nested aggregate functions. Of course the alternative is to
- create intermediate tables, but I should have to do that. I don't
- like having to remember to delete junk tables.
-
- Here is an example of nested group by clauses:
-
- create view tagcountv as
- select id, subentry, tag, count(tag) as tagcount
- from datatable
- GROUP BY ID, SUBENTRY, TAG;
-
- create view tag_max as
- select tag, max(tagcount) as maxcount
- from tagcountv
- GROUP BY TAG;
-
- When I select from tag_max, I get repeats of several of the tags, with
- different maximum counts.
-
- If I change tagcountv to have a group by clause of:
-
- GROUP BY TAG, ID, SUBENTRY
-
- Then the aggregates are calculated properly. Presumably, the problem
- is caused by Ingres not sorting the table resulting from tagcountv,
- before it calculates aggregates for tag_max. Is this a general
- problem with SQL implementations or just an Ingres bug?
-
- -Stephan
-
- Stephan J. Ozminski Bitnet: OZMINSKI@MSUKBS
- Michigan State University Internet: OZMINSKI%KBS.DECNET@CLVAX1.CL.MSU.EDU
- W.K. Kellogg Biological Station
- 3700 E. Gull Lake Dr.
- Hickory Corners, MI 49060
-
-