Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SSRS and & or filters

Posted on 2009-07-09
4
Medium Priority
?
324 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
Chris Luttrell earned 2000 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 27

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by Valentino Vranken. A while ago I wrote an article called Chart Optimization Tips (http://www.experts-exchange.com/articles/Microsoft/Development/MS-SQL-Server/MS-SQL_Reporting/Chart-Optimization-Tips.html).  This article explained how …
How to use Variables  and Custom code in SSRS report and Assembly reference to use compile shared code in SSRS. Its big question for all who are working with SSRS. It is easy to create assembly and refer in SSRS report, still there are some steps…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

715 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