Unix Technical Forum

negate RESULT SET, all inactive client

This is a discussion on negate RESULT SET, all inactive client within the SQL Server forums, part of the Microsoft SQL Server category; --> I' d like to list all inactive clients. Inactive client is a client who hasn't had invoice for 2 ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-01-2008, 03:42 PM
Mike
 
Posts: n/a
Default negate RESULT SET, all inactive client

I' d like to list all inactive clients.
Inactive client is a client who hasn't had invoice for 2 months.

I use INNER JOIN to join invoice view (vwDok4FSFZGrid) and clients
addresses table (adr_Nazwa). I skip empty values (adr_Ewid.adr_Nazwa !
=''). I select only invoices with date after the interesting date.

So now I can list all active clients but i can't negate this result
set to get all inactive clients:

SELECT dok_PlatnikId, adr_Nazwa,
adr_NazwaPelna,adr_Adres,adr_Miejscowosc,adr_NIP, dok_DataWyst
FROM vwDok4FSFZGrid
INNER JOIN adr__Ewid
ON vwDok4FSFZGrid.dok_PlatnikId=adr__Ewid.adr_IdObiek tu
WHERE
adr__Ewid.adr_Nazwa !=''
AND
(dok_DataWyst >= convert(datetime,'10/03/2007'))
GROUP BY dok_PlatnikId, adr_Nazwa,
adr_NazwaPelna,adr_Adres,adr_Miejscowosc,adr_NIP, dok_DataWyst

Is there any way to negate this set?

1. Sorry for my English
2. I would appreciate any help


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-01-2008, 03:42 PM
Erland Sommarskog
 
Posts: n/a
Default Re: negate RESULT SET, all inactive client

Mike (darthvadertojabuahahahaha@gmail.com) writes:
> I' d like to list all inactive clients.
> Inactive client is a client who hasn't had invoice for 2 months.
>
> I use INNER JOIN to join invoice view (vwDok4FSFZGrid) and clients
> addresses table (adr_Nazwa). I skip empty values (adr_Ewid.adr_Nazwa !
>=''). I select only invoices with date after the interesting date.
>
> So now I can list all active clients but i can't negate this result
> set to get all inactive clients:
>
> SELECT dok_PlatnikId, adr_Nazwa,
> adr_NazwaPelna,adr_Adres,adr_Miejscowosc,adr_NIP, dok_DataWyst
> FROM vwDok4FSFZGrid
> INNER JOIN adr__Ewid
> ON vwDok4FSFZGrid.dok_PlatnikId=adr__Ewid.adr_IdObiek tu
> WHERE
> adr__Ewid.adr_Nazwa !=''
> AND
> (dok_DataWyst >= convert(datetime,'10/03/2007'))
> GROUP BY dok_PlatnikId, adr_Nazwa,
> adr_NazwaPelna,adr_Adres,adr_Miejscowosc,adr_NIP, dok_DataWyst
>
> Is there any way to negate this set?


A complete guess:

SELECT adr_Nazwa, adr_NazwaPelna,adr_Adres,adr_Miejscowosc,adr_NIP
FROM adr__Ewid a
WHERE a.adr_Nazwa <> ''
AND NOT EXISTS (SELECT *
FROM vwDok4FSFZGrid v
WHERE v.dok_PlatnikId = a.adr_IdObiektu
AND v.dok_DataWyst >= '20070310')



--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:00 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com