Solved

SSRS and & or filters

Posted on 2009-07-09
4
312 Views
Last Modified: 2012-06-21
I have a questions on Filters  I need soso.status ='open' and SOSOline.Status ='open' that works good but i need to add the IMItems also but now turns the closed as well what am am I during wrong.  
SELECT     SNSalesRep.Name, SOSO.SONumber, SOSO.ShipToName, SOSO.Status, SOSOLine.Status AS Expr1, SOSO.CustomerPO, SOSO.ContactFirstName, 

                      SOSO.ContactLastName, SOSO.WrittenBy, SOSOLine.SOLineNumber, SOSOLine.Item, SOSOLine.Quantity, SOSOLine.DateOrdered, 

                      SOSOLine.DateRequired, SOSOLine.UsePriceOverride, SOSOLine.UnitPriceOverride, SOSOLine.UnitPriceCalculated, SOSOLine.QuantityShipped, 

                      ARCustomer.Name AS Expr2, SOSO.ContactPhone, SOSO.ContactEmail, IMItem.SPC

FROM         SOSO AS SOSO INNER JOIN

                      ARCustomerShipTo AS ARCustomerShipTo ON SOSO.CustomerShipTo = ARCustomerShipTo.CustomerShipTo INNER JOIN

                      SOSOLine AS SOSOLine ON SOSO.SONumber = SOSOLine.SONumber INNER JOIN

                      ARCustomer AS ARCustomer ON ARCustomerShipTo.Customer = ARCustomer.Customer INNER JOIN

                      SOSOLineRep AS SOSOLineRep ON SOSOLine.SONumber = SOSOLineRep.SONumber AND 

                      SOSOLine.SOLineNumber = SOSOLineRep.SOLineNumber INNER JOIN

                      SNSalesRep AS SNSalesRep ON SOSOLineRep.SalesRep = SNSalesRep.SalesRep INNER JOIN

                      IMItem ON SOSOLine.Item = IMItem.Item

WHERE     (SOSO.Status = 'OPEN') AND (SOSOLine.Status = 'OPEN') AND (IMItem.SPC = 'JWGAS') OR

                      (IMItem.SPC = 'JWCG') OR

                      (IMItem.SPC = 'JWOR') OR

                      (IMItem.SPC = 'TORAC')

Open in new window

0
Comment
Question by:gotti777
  • 2
4 Comments
 
LVL 26

Accepted Solution

by:
Chris Luttrell earned 500 total points
ID: 24815101
Put another set of parenthesis around your ORs

WHERE     (SOSO.Status = 'OPEN') AND (SOSOLine.Status = 'OPEN') AND ((IMItem.SPC = 'JWGAS') OR
                      (IMItem.SPC = 'JWCG') OR
                      (IMItem.SPC = 'JWOR') OR
                      (IMItem.SPC = 'TORAC'))
0
 
LVL 26

Expert Comment

by:Chris Luttrell
ID: 24815116
or change it to an IN expression

WHERE     (SOSO.Status = 'OPEN') AND (SOSOLine.Status = 'OPEN') AND (IMItem.SPC IN ('JWGAS', 'JWCG', 'JWOR', 'TORAC'))
0
 
LVL 8

Expert Comment

by:Hadush
ID: 24815130
The OR condition that brings the closed.  Which means even if status values is closed they could have (JWCG, JWOR, TORAC) on its spc column.  Are you trying to do some thing like this one?

 
 

 (SOSO.Status = 'OPEN') AND (SOSOLine.Status = 'OPEN') 

AND 

(

(IMItem.SPC = 'JWGAS') 

OR (IMItem.SPC = 'JWCG') 

OR (IMItem.SPC = 'JWOR')

OR (IMItem.SPC = 'TORAC')

)

Open in new window

0
 

Author Closing Comment

by:gotti777
ID: 31601677
Worked Perfect thank you
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Earlier I wrote an article about the new lookup functions (http://www.experts-exchange.com/A_3433.html) that ship with SQL Server 2008 R2.  In this article I’m going to show you another new feature of SSRS 2008 R2, this time in the vis…
It is helpful to note: This is a cosmetic update and is not required, but should help your reports look better for your boss.  This issue has manifested itself in SSRS version 3.0 is where I have seen this behavior in.  And this behavior is only see…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now