Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Using left join with subquery
Sat, Sep 19 2009 9:34 AMPermanent Link

Davis
Hi,
How can use subquery with dbisam ? The bellow code don't work.
Thanks.

select
s.c_codcli,
s.c_seqauto,

qtd.qtdsessoes

from sessoes s

left join  
( select c_codcli, c_seqauto, count(*) as qtdsessoes from sessoes group by
c_codcli,c_seqauto ) qtd

on (s.c_codcli=qtd.c_codcli and s.c_seqauto=qtd.c_seqauto)
Mon, Sep 21 2009 4:51 AMPermanent Link

"John Hay"
Davi

> How can use subquery with dbisam ? The bellow code don't work.
> Thanks.
>
> select
> s.c_codcli,
> s.c_seqauto,
>
> qtd.qtdsessoes
>
> from sessoes s
>
> left join
> ( select c_codcli, c_seqauto, count(*) as qtdsessoes from sessoes group by
> c_codcli,c_seqauto ) qtd
>
> on (s.c_codcli=qtd.c_codcli and s.c_seqauto=qtd.c_seqauto)

DBISAM does not support subquery/derived tables.  You can use a script like

select c_codcli, c_seqauto, count(*) as qtdsessoes into memory\qtd from
sessoes group by
c_codcli,c_seqauto;
select s.c_codcli,s.c_seqauto,qtd.qtdsessoes from sessoes s
left join qtd on (s.c_codcli=qtd.c_codcli and s.c_seqauto=qtd.c_seqauto)

John




Image