From: nirene via SQLMonster.com on
Sample Data
Type # Amt # Trno # DC # Code # Subcode
ADV # 1000 # 1 #D # 103625 #
ADV # 1000 # 1 #C # 103400 # S1

ADV # 2000 # 2 #D # 103625 #
ADV # 2000 # 2 #C # 103400 # S2

VES # 5000 # 1 #D # 103400 # S1
VES # 5000 # 1 #C # 300070 # S1

Now I wanna find out the details of Code & Subcode of Type(VES) which does
not match with Type ADV

Expected result should come with subcode of the other record

ADV # 2000 # 2 #D # 103625 # S2

Thanks in advance

Nirene

--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server-programming/201004/1

From: John Bell on
On Sat, 24 Apr 2010 04:38:36 GMT, "nirene via SQLMonster.com"
<u45873(a)uwe> wrote:

>Sample Data
>Type # Amt # Trno # DC # Code # Subcode
>ADV # 1000 # 1 #D # 103625 #
>ADV # 1000 # 1 #C # 103400 # S1
>
>ADV # 2000 # 2 #D # 103625 #
>ADV # 2000 # 2 #C # 103400 # S2
>
>VES # 5000 # 1 #D # 103400 # S1
>VES # 5000 # 1 #C # 300070 # S1
>
>Now I wanna find out the details of Code & Subcode of Type(VES) which does
>not match with Type ADV
>
>Expected result should come with subcode of the other record
>
>ADV # 2000 # 2 #D # 103625 # S2
>
>Thanks in advance
>
>Nirene

You can use NOT EXISTS see
http://msdn.microsoft.com/en-us/library/ms188336.aspx

John