Solved

How to put a condition on a condition in SQL

Posted on 2009-05-08
2
703 Views
Last Modified: 2013-12-19
I'm trying to write a query to list sales orders that have SKUs that have a Hazmat ID attached to them.  I'm looking for 2 different Hazmat ID's. I can get the orders with the Hazmat skus to come up but I want to refine the search. The only orders I need to be return are orders that has SKUs with quantities of =<3 for Hazmat code 'LIA311' and =<5 for Hazmat code 'LIA511'
select IN_.HAZMAT_ID, OR_.SO_BR_ID||OR_.SO_ID, OR_.CUST_NAME, OR_.STATUS, OR_.CARRIER_ROUTE,OR_1.PART_ID, OR_1.QTY_ORDERED, OR_.PICK_BATCH_ID
from CSI.IN_INFORMATION IN_, CSI.OR_HEADER OR_, CSI.OR_LINE OR_1
where OR_1.PART_ID = IN_.PART_ID
	and OR_.SO_BR_ID = OR_1.SO_BR_ID
	and OR_.SO_ID = OR_1.SO_ID
	and (IN_.HAZMAT_ID IN ('LIA311', 'LIA511'))
	and (OR_.STATUS = 'R')
    and (OR_.CARRIER_ROUTE in ('F1', 'F2', 'FO', 'FS', 'UO', 'UB', 'US', 'U3', 'CL', 'PG'))

Open in new window

hazmat.doc
0
Comment
Question by:Jbancr1
[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 Comments
 
LVL 11

Accepted Solution

by:
Andytw earned 500 total points
ID: 24337487
Hi try this ...
SELECT IN_.HAZMAT_ID,
       OR_.SO_BR_ID || OR_.SO_ID,
       OR_.CUST_NAME,
       OR_.STATUS,
       OR_.CARRIER_ROUTE,
       OR_1.PART_ID,
       OR_1.QTY_ORDERED,
       OR_.PICK_BATCH_ID
FROM   CSI.IN_INFORMATION IN_,
       CSI.OR_HEADER      OR_,
       CSI.OR_LINE        OR_1
WHERE  OR_1.PART_ID = IN_.PART_ID
AND    OR_.SO_BR_ID = OR_1.SO_BR_ID
AND    OR_.SO_ID = OR_1.SO_ID
AND    ( (IN_.HAZMAT_ID = 'LIA311' AND OR_1.QTY_ORDERED <= 3) OR
         (IN_.HAZMAT_ID = 'LIA511' AND OR_1.QTY_ORDERED <= 5) )
AND    (OR_.STATUS = 'R')
AND    (OR_.CARRIER_ROUTE IN ('F1', 'F2', 'FO', 'FS', 'UO', 'UB', 'US', 'U3', 'CL', 'PG'))

Open in new window

0
 

Author Closing Comment

by:Jbancr1
ID: 31579396
Thanks just what I was looking for.
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Hello, In my precious Article  (http://www.experts-exchange.com/Database/Reporting/A_15280-Create-Project-in-Microstrategy-Part-I.html)we saw the Configuration part for Microstrategy which included Metadata Creation and DataSource Preparation as …
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

734 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