Welcome Guest Search | Active Topics | Members | Log In | Register

Re: Question regarding use of a join to the same table Options · View
Hugo Kornelis
Posted: Friday, October 19, 2007 2:47:07 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 19/10/2007 02:47:07
Date: Fri, 19 Oct 2007 00:47:07 +0200

On Tue, 16 Oct 2007 08:42:02 -0700, Joe wrote:

>I tried a simpler stetment:
>
>select A.BUSINESS_UNIT, A.ASSET_ID, A.BOOK
>from PS_BOOK A
>where EXISTS (select 'x'
> from PS_BOOK B
> where B.BOOK <> 'AMT')
>order by A.BUSINESS_UNIT, A.ASSET_ID, A.BOOK
>
>But I still get both the BU/Asset combination that has 'AMT' as well as the
>combination that does not have 'AMT'.

Hi Joe,

I think you want this one:

SELECT a.BusinessUnit, a.AssetID, a.Book
FROM PS_Book AS a
WHERE NOT EXISTS
(SELECT *
FROM PS_Book AS b
WHERE b.BusienssUnit = a.BusinessUnit
AND b.AssetID = a.AssetID
AND b.Book <> 'AMT');

If that is not it, then see www.aspfaq.com/5006 to find the information
you need to post in order to make it possible for us to help you.

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFPro Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.1 (NET v2.0) - 9/10/2007
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.072 seconds.