Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #121

Re: I Need help with a query...

From "Bob Barrows" <reb01501@NOSPAMyahoo.com>
Newsgroups comp.databases.ms-sqlserver
Subject Re: I Need help with a query...
Date 2011-04-05 07:38 -0400
Organization A noiseless patient Spider
Message-ID <inev26$j0g$1@dont-email.me> (permalink)
References <ab761644-26ae-41c4-a599-acb60a80ae69@n12g2000yqc.googlegroups.com>

Show all headers | View raw


Alfaking wrote:
> hello.
> I need help with a query please...
> whenever i found a type "T", I have to exclude that number of "contr".
>
> I'm able to exclude all the records where type is not "T", but if I
> found type ="T", that contr goes into results because of the ID
> field...
>
> any idea of how I can do this ?

Just to follow up, if other contract types exist, and you need to retrieve 
all IDs and types for the contracts that don't have a T type, then this will 
do it:

select id,contr,type
from table t
where not exists (
select * from table where
contr = t.contr and type = 'T') 

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

I Need help with a query... Alfaking <favia.alessandro@gmail.com> - 2011-04-05 00:30 -0700
  Re: I Need help with a query... Henk van den Berg <hvandenberg@xs4all.nl> - 2011-04-05 10:09 +0200
    Re: I Need help with a query... Alfaking <favia.alessandro@gmail.com> - 2011-04-05 01:54 -0700
      Re: I Need help with a query... Henk van den Berg <hvandenberg@xs4all.nl> - 2011-04-05 10:59 +0200
        Re: I Need help with a query... Alfaking <favia.alessandro@gmail.com> - 2011-04-05 02:14 -0700
          Re: I Need help with a query... Henk van den Berg <hvandenberg@xs4all.nl> - 2011-04-05 11:29 +0200
      Re: I Need help with a query... Lutz Uhlmann <news@invalid.invalid> - 2011-04-05 11:50 +0200
        Re: I Need help with a query... Alfaking <favia.alessandro@gmail.com> - 2011-04-05 04:04 -0700
      Re: I Need help with a query... Alfaking <favia.alessandro@gmail.com> - 2011-04-05 03:57 -0700
        Re: I Need help with a query... Henk van den Berg <hvandenberg@xs4all.nl> - 2011-04-05 13:07 +0200
  Re: I Need help with a query... "Bob Barrows" <reb01501@NOSPAMyahoo.com> - 2011-04-05 07:17 -0400
    Re: I Need help with a query... Henk van den Berg <hvandenberg@xs4all.nl> - 2011-04-05 13:33 +0200
      Re: I Need help with a query... "Bob Barrows" <reb01501@NOSPAMyahoo.com> - 2011-04-05 07:40 -0400
        Re: I Need help with a query... Henk van den Berg <hvandenberg@xs4all.nl> - 2011-04-05 14:26 +0200
  Re: I Need help with a query... "Bob Barrows" <reb01501@NOSPAMyahoo.com> - 2011-04-05 07:38 -0400

csiph-web