Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Except in SQL
Thu, Apr 2 2009 4:40 AMPermanent Link

Hiba Hable
Hello,

i am trying to execute the follwing sql statment but i am getting an error, i need to know how to write "except" in dbisam.

(select cnr,bl from histcnr where act='BOOK' union
select cnr,bl from histcnr where (act='DCMT' and pod='LBBEY') union
select cnr,bl from histcnr where act='RMTY')
except
(select cnr,bl from histcnr where act='DMEX' union
select cnr,bl from histcnr where act='LDMT' or act='LDFL')

Thanks

Hiba
Thu, Apr 2 2009 5:16 AMPermanent Link

"John Hay"
Hiba

> i am trying to execute the follwing sql statment but i am getting an
error, i need to know how to write "except" in dbisam.
>
> (select cnr,bl from histcnr where act='BOOK' union
> select cnr,bl from histcnr where (act='DCMT' and pod='LBBEY') union
> select cnr,bl from histcnr where act='RMTY')
> except
> (select cnr,bl from histcnr where act='DMEX' union
> select cnr,bl from histcnr where act='LDMT' or act='LDFL')

DBIsam does not support derived tables.

In this particular case does the following produce the correct result?

select cnr,bl from histcnr where act='BOOK' union
select cnr,bl from histcnr where (act='DCMT' and pod='LBBEY') union
select cnr,bl from histcnr where act='RMTY'
except
select cnr,bl from histcnr where act='DMEX' union or act='LDMT' or
act='LDFL'

John

Thu, Apr 2 2009 6:19 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Hiba,

The correct sintax to do what you want is:

select cnr,bl from histcnr where act='BOOK'
union
select cnr,bl from histcnr where act='DCMT' and pod='LBBEY'
union
select cnr,bl from histcnr where act='RMTY'
except
select cnr,bl from histcnr where act='DMEX'
except
select cnr,bl from histcnr where act='LDMT' or act='LDFL'

--
Fernando Dias
[Team Elevate]

Image