Subject | Re: [firebird-support] Re: help with a select, i m out of ideas. |
---|---|
Author | Fabio Gomes |
Post date | 2006-03-31T13:00:23Z |
This worked on the first try.
thanx guys :)
On 3/31/06, Svein Erling Tysvær <svein.erling.tysvaer@...>
wrote:
thanx guys :)
On 3/31/06, Svein Erling Tysvær <svein.erling.tysvaer@...>
wrote:
>[Non-text portions of this message have been removed]
> --- In firebird-support@yahoogroups.com, "Fabio Gomes" wrote:
> > 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?
>
> Sure, your query is incorrect! NEVER define the same alias twice in
> the same query (you could use C2 for the second clientes alias, but in
> your case you're better off just removing it altogether)!!!
>
> Your simplified query should probably just be:
>
>
> SELECT C.cli_nome
> FROM clientes C
> WHERE NOT EXISTS (
> SELECT V.vnd_cod
> FROM vendas V
> WHERE V.cli_cod=C.cli_cod
> AND V.vnd_data BETWEEN '2006-03-01' AND '2006-03-31'
> )
> AND C.ved_cod='2'
>
> HTH,
> Set
>
>
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> 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/>.
>
>
> ------------------------------
>