Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL select statement issue

Author  Topic 

daniel50096230
Yak Posting Veteran

99 Posts

Posted - 2009-10-14 : 03:27:50
I had the following SQL select statement:
select t.placedelivery,d.itemdesc,t.qty,(d.casecost * t.qty)AS cost from trn_po p,trn_po_details d, trn_po_trailers t where d.poid=p.poid and t.poid=p.poid and d.[lineno]=t.[lineno] and podt>'2009-10-01' and EXISTS(Select * from trn_po_trailers where poid=p.poid and placedelivery='03999')

The results I get as the following:
placedelivery itemdesc qty cost
------------- ------------ ----------------- ----------------
03999 RAMBUTAN 7.0000 137.0600
03005 RAMBUTAN 6.0000 117.4800

However, what I expected is only data for 03999 is display but not 03005 to be display also.

Any idea on how to modified my sql?

PeterNeo
Constraint Violating Yak Guru

357 Posts

Posted - 2009-10-14 : 05:33:34
try this
select t.placedelivery,d.itemdesc,t.qty,(d.casecost * t.qty)AS cost
from trn_po p, trn_po_details d, trn_po_trailers t
where d.poid=p.poid and t.poid=p.poid and d.[lineno]=t.[lineno]
and podt>'2009-10-01' and EXISTS(Select * from trn_po_trailers where poid=p.poid and placedelivery='03999'
and placedelivery = t.placedelivery)

"There is only one difference between a dream and an aim.
A dream requires soundless sleep to see,
whereas an aim requires sleepless efforts to achieve..!!"
Go to Top of Page
   

- Advertisement -