Home » SQL & PL/SQL » SQL & PL/SQL » query help
query help [message #607967] Fri, 14 February 2014 00:07 Go to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Hi all,

Check the item whether it is in both organization or not and active . I want a query on this please help
Re: query help [message #607969 is a reply to message #607967] Fri, 14 February 2014 00:16 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
I have 2 tables
1) mtl_system_items_kfv(CONCATENATED_SEGMENTS,ORGANIZATION_ID)

2) ORG_ORGANIZATION_DEFINITIONS(ORGANIZATION_ID)

with this 2 tables i want to bulid a query ., check whether it is available in the ORG_ORGANIZATION_DEFINITIONS or not
Re: query help [message #607972 is a reply to message #607969] Fri, 14 February 2014 00:31 Go to previous messageGo to next message
Michel Cadot
Messages: 68643
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Define "available".
If it only means "exists" then this is a basic SQL for someone that has posted more than 500 messages (but maybe not for someone that does not understand that "query help" is a silly title in a SQL forum).


[Updated on: Fri, 14 February 2014 00:33]

Report message to a moderator

Re: query help [message #607973 is a reply to message #607972] Fri, 14 February 2014 00:34 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
SELECT a.organization_id,
       a.concatenated_segments,
       a.inventory_item_status_code
FROM   mtl_system_items_kfv a
WHERE  EXISTS(SELECT 1
              FROM   org_organization_definitions b
              WHERE  a.organization_id = b.organization_id)
       AND inventory_item_status_code = 'Active'
        OR inventory_item_status_code = 'Inactive'
           AND concatenated_segments = Nvl(:CONCATENATED_SEGMENTS, 0)  


Is this correct query?Please help
Re: query help [message #607977 is a reply to message #607973] Fri, 14 February 2014 00:43 Go to previous messageGo to next message
Michel Cadot
Messages: 68643
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

This is correct if it returns the expected result.Is this the case?
Can there be other "inventory_item_status_code" than the ones in the query?

Re: query help [message #607979 is a reply to message #607977] Fri, 14 February 2014 00:50 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Quote:
Can there be other "inventory_item_status_code" than the ones in the query?


No sir, it is only column in the mtl_system_items_kfv table
Re: query help [message #607984 is a reply to message #607979] Fri, 14 February 2014 01:05 Go to previous messageGo to next message
Michel Cadot
Messages: 68643
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

I meant are 'Active' and 'Inactive' the only values in this column?
Does the query returns the correct result?
How can we know the data in your tables?
How can we know your model?

Re: query help [message #607991 is a reply to message #607984] Fri, 14 February 2014 01:29 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
1)I have org_organization_definitions(organization_id (81,82))
2)Items table mtl_system_items_kfv(ORGANIZATION_ID,CONCATENATED_SEGMENTS,INVENTORY_ITEM_STATUS_CODE)

I want to check CONCATENATED_SEGMENTS(items column)whether it is in the organization_id (81,82) or not..and active .
The INVENTORY_ITEM_STATUS_CODE column contain Active and Inactive
Please help me
Re: query help [message #607993 is a reply to message #607991] Fri, 14 February 2014 01:34 Go to previous messageGo to next message
Michel Cadot
Messages: 68643
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

You still didn't answer to ALL my questions.

Re: query help [message #607994 is a reply to message #607993] Fri, 14 February 2014 01:38 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Quote:

I meant are 'Active' and 'Inactive' the only values in this column?
Does the query returns the correct result?


Yes, 'Active' and 'Inactive' the only values in this column and
Re: query help [message #607996 is a reply to message #607994] Fri, 14 February 2014 01:48 Go to previous message
Michel Cadot
Messages: 68643
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

So:
inventory_item_status_code = 'Active'
OR inventory_item_status_code = 'Inactive'
is always true.

Note that some parentheses are missing in your query.

Previous Topic: Convert rows into columns
Next Topic: check ordernum present in that column-PLS-00103: Encountered the symbol "SP_LOAD_ORDER" when expecti
Goto Forum:
  


Current Time: Tue Apr 23 08:48:07 CDT 2024