dbTalk Databases Forums  

Re: SQL query problem

microsoft.public.sqlserver.misc microsoft.public.sqlserver.misc


Discuss Re: SQL query problem in the microsoft.public.sqlserver.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
John Bell
 
Posts: n/a

Default Re: SQL query problem - 10-11-2003 , 08:43 AM






Hi

It is alot easier if you post the DDL (Create table statements) Example data
(as insert statements) as well as your query
and expected results.

As you already have a join then I am not sure why you have problems joining
the extra table. What errors are you getting.?

A guess would be:
SELECT b.btdnumber as btdnumber,
b.btdtrfno as bbtdtrfno,
a.btdtrfno as btdtrfnohidden,
a.BtdAcno as BtdAcno,
a.BtdCertNo as BtdCertNo,
a.BtdShare as BtdShare,
c.shmName as shmName
FROM shrbatchdetail a
RIGHT OUTER join shrbatchdetail b on a.btdrecid = b.btdrecid and
a.btdsellbuy = 'S'
JOIN shrShareMaster c ON c.shmacno = b.btdacno


John
"Omavlana" <kiran (AT) boardroomlimited (DOT) com> wrote

Quote:
Hi, I hv the following query that is returning correct values.
However, I want to add one more condition to this query.

select b.btdnumber as btdnumber,
b.btdtrfno as bbtdtrfno,
a.btdtrfno as btdtrfnohidden,
a.BtdAcno as BtdAcno,
a.BtdCertNo as BtdCertNo,
a.BtdShare as BtdShare
from shrbatchdetail a
right outer join shrbatchdetail b
on a.btdrecid = b.btdrecid
and a.btdsellbuy = 'S'

Along with the above details and satisfying above conditions, I want
to get

c.shmName from shrShareMaster c where c.shmacno = b.btdacno

Pls help me to modify the query.

-Omav



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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.