Unix Technical Forum

SQL query problem

This is a discussion on SQL query problem within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi, I hv the following query that is returning correct values. However, I want to add one more condition ...


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 02-28-2008, 06:12 PM
Omavlana
 
Posts: n/a
Default SQL query problem

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 06:12 PM
Anith Sen
 
Posts: n/a
Default Re: SQL query problem

Always post table DDLs, sample data & expected results for such
requirements. Here is my guess:

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
FROM shrbatchdetail a
RIGHT OUTER JOIN shrbatchdetail b
ON a.btdrecid = b.btdrecid
AND a.btdsellbuy = 'S'
INNER JOIN shrShareMaster c
ON c.shmacno = b.btdacno ;

--
--- Anith


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 12:33 PM.


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