home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.databases.sybase
- Path: sparky!uunet!shearson.com!newshost!wfinnert
- From: wfinnert@larry.shearson.com (Warren Finnerty)
- Subject: Re: Sybase 4.9.1 Returns the Wrong Rows
- In-Reply-To: hanafey@eplrx7.es.dupont.com's message of Tue, 19 Jan 1993 13:44:19 GMT
- Message-ID: <WFINNERT.93Jan20231914@larry.shearson.com>
- Sender: news@shearson.com (News)
- Organization: Lehman Brothers
- References: <1993Jan19.134419.27020@eplrx7.es.duPont.com>
- Date: Thu, 21 Jan 1993 04:19:14 GMT
- Lines: 83
-
- >In article <1993Jan19.134419.27020@eplrx7.es.duPont.com> hanafey@eplrx7.es.dupont.com (Mike Hanafey) writes:
-
- > Sybase returns the wrong result for the following simple query:
- >
- > 1> select c.c1 from c where (select count(*) from b where b.c1 = c.c1) > 1
- > 2> go
- > c1
- > -----------
- > 2
- > 2
- > 3
- > 3
- > 3
- > (5 rows affected)
- >
- > Given the tables below, the correct result should be zero rows selected:
-
-
- [ tables deleted ]
-
- This type of query *DOES* work in 4.0.1.
- First make sure you have the latest 4.9.1 EBF.
- Second add a "group by b.c1" to the subquery that might well fix it.
-
-
- > Sybase also returns incorrect results for a query with a "group by" that includes
- > the Transact-SQL extension that not every column in the select list must be an
- > aggregate, or a grouped by column:
- >
- > 1> select b.c1,b.c2,a.c1,count(a.c2) from a,b where a.c1=b.c1 group by a.c1
- > 2> go
- > c1 c2 c1
- > ----------- ----------- ----------- -----------
- > 1 0 1 3
- > 2 0 1 3
- > 3 0 1 3
- > 1 0 2 3
- > 2 0 2 3
- > 3 0 2 3
- > (6 rows affected)
- >
- > The first column here contains "3", a curious result considering that this column was
- > equi-joined to the third column, which has no "3". Here are the input tables:
- >
- > 1> select * from b
- > 2> go
- > c1 c2
- > ----------- -----------
- > 1 0
- > 2 0
- > 3 0
- > (3 rows affected)
- >
- > 1> select * from a
- > 2> go
- > c1 c2
- > ----------- -----------
- > 1 1
- > 1 2
- > 1 3
- > 2 1
- > 2 1
- > 2 1
- > (6 rows affected)
-
- Answer: Include all the non-aggr cols in the select list in the "GROUP BY"
- or use COMPUTE.
-
- Despite documentation to the contrary, attempts to do otherwise
- ( esp. with joins ) result in BUG-city.
-
-
- > Mike Hanafey
- > Dupont Experimental Station
- > hanafey@suncity.es.dupont.com
- > --
-
- Good luck.
- --
- warren finnerty | 388 Greenwich St.
- Lehman Brothers | NYC NY 10013
- "Back off man!" | wfinnert@shearson.com
-
-