Subject | Re: [firebird-support] Re: help with a select, i m out of ideas. |
---|---|
Author | Fabio Gomes |
Post date | 2006-03-30T11:59:59Z |
Hi i have doubts again ^^
I tried this:
SELECT C.cli_nome
FROM clientes C
WHERE NOT EXISTS (
SELECT V.vnd_cod
FROM vendas V, clientes C
WHERE V.cli_cod=C.cli_cod AND V.vnd_data BETWEEN '2006-03-01' AND
'2006-03-31' AND C.ved_cod='2'
)
AND C.ved_cod='2'
I tought it worked on the first time, but it just give me results if i dont
have any records on the vendas table, and what i want is all the clients
(clientes) that doesnt have any records in the vendas table.
This query above just give me results if i dont have ANY records on the
vendas table.
Is there a way to fix it?
I tried this:
SELECT C.cli_nome
FROM clientes C
WHERE NOT EXISTS (
SELECT V.vnd_cod
FROM vendas V, clientes C
WHERE V.cli_cod=C.cli_cod AND V.vnd_data BETWEEN '2006-03-01' AND
'2006-03-31' AND C.ved_cod='2'
)
AND C.ved_cod='2'
I tought it worked on the first time, but it just give me results if i dont
have any records on the vendas table, and what i want is all the clients
(clientes) that doesnt have any records in the vendas table.
This query above just give me results if i dont have ANY records on the
vendas table.
Is there a way to fix it?
On 3/30/06, Fabio Gomes <fabioxgn@...> wrote:
>
> Wow.. so simple ^^
>
> Thanx a lot!
>
>
> On 3/30/06, Helen Borrie <helebor@...> wrote:
> >
> > At 09:07 PM 30/03/2006, you wrote:
> > >Anyway, sorry about all those newbie questions, but i have another one
> > ^^
> > >
> > >Now i need to make a report that shows all the clients that didnt buy
> > >anything on that month.. so i tried this:
> > >
> > >SELECT C.cli_nome
> > >FROM clientes C, vendas V
> > >WHERE (SELECT V.vnd_cod FROM vendas V, clientes C WHERE
> > V.cli_cod=C.cli_cod)
> > >IS NULL AND V.vnd_data BETWEEN '2006-1-01' AND '2006-1-31'
> > >
> > >I dont really understand how subselects work so i just guessed it, and
> > it
> > >seens that i ve guessed it wrong, cause it didnt work.
> > >
> > >Could you guys help me out with this too?
> >
> > SELECT
> > C.cli_nome
> > FROM clientes C
> > WHERE NOT EXISTS (
> > SELECT 1 FROM vendas V
> >
> > WHERE V.cli_cod=C.cli_cod
> > AND V.vnd_data BETWEEN '2006-1-01' AND '2006-1-31')
> >
> > ./hb
> >
> >
> >
> >
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >
> > Visit http://firebird.sourceforge.net and click the Resources item
> > on the main (top) menu. Try Knowledgebase and FAQ links !
> >
> > Also search the knowledgebases at http://www.ibphoenix.com
> >
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >
> >
> >
> > ------------------------------
> > YAHOO! GROUPS LINKS
> >
> >
> > - Visit your group "firebird-support<http://groups.yahoo.com/group/firebird-support>"
> > on the web.
> >
> > - To unsubscribe from this group, send an email to:
> > firebird-support-unsubscribe@yahoogroups.com<firebird-support-unsubscribe@yahoogroups.com?subject=Unsubscribe>
> >
> > - Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> > Service <http://docs.yahoo.com/info/terms/> .
> >
> >
> > ------------------------------
> >
>
>
[Non-text portions of this message have been removed]