Solved

How to add the filter

Posted on 2012-04-10
2
291 Views
Last Modified: 2012-05-17
only when
mmt.transaction_type_id IN (31, 41) then
 mmt.transaction_source_id=2878

how to add this filter in the below query

SELECT mmt.inventory_item_id,
               p_org_id,
               p_date,
               p_quarter,
               msi.item_type,
               SUM (primary_quantity)
          FROM mtl_material_transactions mmt, mtl_system_items_b msi
         WHERE     mmt.inventory_item_id = msi.inventory_item_id
               AND mmt.organization_id = msi.organization_id
               AND mmt.organization_id = p_org_id
               AND mmt.transaction_type_id IN (35, 33, 62, 34,31, 41)
               --and mmt.transaction_source_id=2878
               AND mmt.transaction_date BETWEEN TO_DATE ('01/01/' || p_date,
                                                         'MM/DD/YYYY')
                                            AND TO_DATE (
                                                      '12/31/'
                                                   || p_date
                                                   || ' 23:59:59',
                                                   'MM/DD/YYYY HH24:MI:SS')
               AND mmt.transaction_date BETWEEN (SELECT ADD_MONTHS (
                                                           LAST_DAY (
                                                              TO_DATE (
                                                                 '01'
                                                                 || TO_CHAR (
                                                                       p_quarter
                                                                       * 3,
                                                                       '09')
                                                                 || p_date,
                                                                 'DDMMYYYY'))
                                                           + 1,
                                                           -3)
                                                           "Begins"
                                                   FROM DUAL)
                                            AND (SELECT LAST_DAY (
                                                           TO_DATE (
                                                              '01'
                                                              || TO_CHAR (
                                                                    p_quarter
                                                                    * 3,
                                                                    '09')
                                                              || p_date,
                                                              'DDMMYYYY'))
                                                        + 86399 / 86400
                                                           "Ends"
                                                   FROM DUAL)
               AND msi.item_type = p_item_type
      GROUP BY mmt.inventory_item_id,
               p_org_id,
               p_date,
               p_quarter,
               msi.item_type;
0
Comment
Question by:pardeshirahul
2 Comments
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 37829051
I'm not understanding the question.

You already have those types in the IN clause and the source_id is commented out in the whree clause:

...
 AND mmt.transaction_type_id IN (35, 33, 62, 34,31, 41)
               --and mmt.transaction_source_id=2878
...


What are you wanting to do?  If you have added them and it isn't working, please clarify.
0
 
LVL 32

Accepted Solution

by:
awking00 earned 500 total points
ID: 37829098
Is this what you're looking for?
WHERE ...
AND ((mmt.transaction_type_id IN (35,33,62,34) OR
     (mmt.transaction_type_id IN (31,41) AND mmt.transaction_source_id = 2878))
...
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.

776 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