Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v7.1
  HXTT Cobol v5.0
  HXTT DBF v7.1
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Excel v6.1
  HXTT Paradox v7.1
  HXTT PDF v2.0
  HXTT Text(CSV) v7.1
  HXTT Word v1.1
  HXTT XML v4.0
Offshore Outsourcing
Free Resources
  Firewall Tunneling
  Search Indexing Robot
  Conditional Compilation
  Password Recovery for MS Access
  Password Recovery for Corel Paradox
  Checksum Tool for MD5
  Character Set Converter
  Pyramid - Poker of ZYH
   
   
   
Heng Xing Tian Tai Lab of Xi'an City (abbr, HXTT)

HXTT DBF
Having-condition in exists-clause
Rob Gansevles
2011-03-09 00:03:32.0
Hello,

One of our test cases failed on the dbf driver, we test an having-condition in an exists-clause.

The sql listed below shows the issue.
It is a query for records in table A that have more than 1 detail record in table B.
The query should only return record A.a=1 but record A.a=2 is also returned.

Thanks in advance for looking at this,
Rob

create table tsta (a int)
create table tstb (b int, a int)

insert into tsta (a) values (1)
insert into tsta (a) values (2)

insert into tstb(b, a) values (10, 1)
insert into tstb(b, a) values (11, 1)
insert into tstb(b, a) values (12, 2)

select outera.a from tsta outera
where exists (select 1 from tsta innera
inner join tstb innerb on innerb.a = innera.a
where innera.a = outera.a
having count(innerb.b) > 1)
Re:Having-condition in exists-clause
HXTT Support
2011-03-09 00:48:13.0
HAVING clause is used in combination with the GROUP BY clause. Because you omitted the GROUP BY clause, so that it will merge it as a where condition.
The correct sql should be
select outera.a from tsta outera
where exists (select 1 from tsta innera
inner join tstb innerb on innerb.a = innera.a
where innera.a = outera.a
group by innera.a /* add here */
having count(innerb.b) > 1)
Re:Re:Having-condition in exists-clause
Rob Gansevles
2011-03-09 01:54:26.0
Ok, I will adjust the sql.

Thanks

Rob

Search Key   Search by Last 50 Questions




Google
 

Email: webmaster@hxtt.com
Copyright © 2003-2019 Heng Xing Tian Tai Lab of Xi'an City. | All Rights Reserved. | Privacy | Legal | Sitemap