query to view separate lines that have the same values
Hello
I have the columns id, addr1, addr2, city and State of coding. I need to know all the coding IDS that have the same addresses and at the same time filter out the same side of the id of the request.
For example:
acctid addr1, addr2 City State
WEF 1 101 101 sd
1 101 wef sd
WEF 2 101 101 sd
WEF 3 101 101 sd
DC 4 102 102 homeless
From the above data, I want to get filter tier 4 and get lines 1, 2 and 3. How to achieve with a sql query
Thank you
Arch
This has nothing to do with hard... coding is how you test a query without creating the table, so you'd:
with match_finder AS (SELECT acctid, addr1, addr2, city, State, count (*) OVER (PARTITION BY addr1, addr2, city, province) AS identical_rows)
OF
Select acctid, addr1, addr2, city, province of match_finder where identical_rows > 1 / and the rest, I'm sure, you can find on your own... HTH
Tags: Database
Similar Questions
-
Stuck on a sql query to search for records that have the same parent child records
Oracle 10 g 2 Enterprise Edition.
Hello
I'm writing a logic to find records in a parent table, who have the same values in a child table.
This is part of a larger application, but I am stuck on that part for now, so I have mocked some of the below simplified tables to capture the heart of the
the problem is that I'm stuck.
Let's say I have a responsible parent, child employee table table and there are a number of many relationships between them.
The aptly named Join_Table manages the relationship between them. If a manager can manage several employees, an employee can be managed by
many managers.
I have a feeling it's stupidly easy, but it seems to me having a bad episode of brain freeze today!
If I ask for Manager John, so I want to find other managers who manage the exact list and even employees.-- parent table CREATE TABLE manager ( id number primary key, name varchar2(100)); -- child table CREATE TABLE employee ( id number primary key, name varchar2(100)); -- link table CREATE TABLE join_table ( manager_id NUMBER, employee_id NUMBER, CONSTRAINT join_table_pk PRIMARY KEY (manager_id, employee_id), CONSTRAINT manager_fk FOREIGN KEY (manager_id) REFERENCES manager(id), CONSTRAINT employee_fk FOREIGN KEY (employee_id) REFERENCES employee(id) ); -- Insert some managers INSERT INTO manager (id, name) VALUES (1, 'John'); INSERT INTO manager (id, name) VALUES (2, 'Bob'); INSERT INTO manager (id, name) VALUES (3, 'Mary'); INSERT INTO manager (id, name) VALUES (4, 'Sue'); INSERT INTO manager (id, name) VALUES (5, 'Alan'); INSERT INTO manager (id, name) VALUES (6, 'Mike'); -- Insert some employees INSERT INTO employee (id, name) VALUES (101, 'Paul'); INSERT INTO employee (id, name) VALUES (102, 'Simon'); INSERT INTO employee (id, name) VALUES (103, 'Ken'); INSERT INTO employee (id, name) VALUES (104, 'Kevin'); INSERT INTO employee (id, name) VALUES (105, 'Jack'); INSERT INTO employee (id, name) VALUES (106, 'Jennifer'); INSERT INTO employee (id, name) VALUES (107, 'Tim'); -- Insert the links -- John manages Paul, Simon, Ken INSERT INTO join_table (manager_id, employee_id) VALUES (1, 101); INSERT INTO join_table (manager_id, employee_id) VALUES (1, 102); INSERT INTO join_table (manager_id, employee_id) VALUES (1, 103); -- Bob manages Paul, Simon, Kevin, Jack INSERT INTO join_table (manager_id, employee_id) VALUES (2, 101); INSERT INTO join_table (manager_id, employee_id) VALUES (2, 102); INSERT INTO join_table (manager_id, employee_id) VALUES (2, 104); INSERT INTO join_table (manager_id, employee_id) VALUES (2, 105); -- Mary manages Jennifer, Tim INSERT INTO join_table (manager_id, employee_id) VALUES (3, 106); INSERT INTO join_table (manager_id, employee_id) VALUES (3, 107); -- Sue manages Jennifer, Tim INSERT INTO join_table (manager_id, employee_id) VALUES (4, 106); INSERT INTO join_table (manager_id, employee_id) VALUES (4, 107); -- Alan manages Paul, Simon, Ken, Jennifer, Tim INSERT INTO join_table (manager_id, employee_id) VALUES (5, 101); INSERT INTO join_table (manager_id, employee_id) VALUES (5, 102); INSERT INTO join_table (manager_id, employee_id) VALUES (5, 103); INSERT INTO join_table (manager_id, employee_id) VALUES (5, 106); INSERT INTO join_table (manager_id, employee_id) VALUES (5, 107); -- Mike manages Paul, Simon, Ken INSERT INTO join_table (manager_id, employee_id) VALUES (6, 101); INSERT INTO join_table (manager_id, employee_id) VALUES (6, 102); INSERT INTO join_table (manager_id, employee_id) VALUES (6, 103); -- For sanity CREATE UNIQUE INDEX employee_name_uidx ON employee(name);
Answer should be Mike.
If I ask for Manager of Mary, the answer should be Sue.
This query will give me the list of managers who manage some of the same employees as John, but not the same employees accurate...
I thought about using set operations to find managers with a list of employees less than my employees is null and where my employees under their list of employees is null. But there must be an easier way more elegant.SELECT DISTINCT m.name AS manager FROM manager m, join_table jt, employee e WHERE m.id = jt.manager_id AND jt.employee_id = e.id AND e.id IN ( SELECT e.id FROM manager m, join_table jt, employee e WHERE m.id = jt.manager_id AND jt.employee_id = e.id AND m.name = 'John') ORDER BY 1;
Any ideas?
BTW, I need to run as a batch on tables with > 20 million rows so the efficiency of queries is key.What about...
WITH manager_list AS ( SELECT name, LTRIM(MAX(SYS_CONNECT_BY_PATH(id,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees FROM (SELECT m.name, e.id, ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) AS curr, ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) -1 AS prev FROM manager m, join_table jt, employee e WHERE m.id = jt.manager_id AND jt.employee_id = e.id AND m.name = :P_MANAGER) GROUP BY name CONNECT BY prev = PRIOR curr AND name = PRIOR name START WITH curr = 1 ), all_list AS ( SELECT name, LTRIM(MAX(SYS_CONNECT_BY_PATH(id,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees FROM (SELECT m.name, e.id, ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) AS curr, ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) -1 AS prev FROM manager m, join_table jt, employee e WHERE m.id = jt.manager_id AND jt.employee_id = e.id) GROUP BY name CONNECT BY prev = PRIOR curr AND name = PRIOR name START WITH curr = 1 ) SELECT a.* FROM manager_list m, all_list a WHERE m.employees = a.employees
Would be easier in 11g, but I do not have a facility here so this is based on 10g.
See you soon
Ben
-
Only GET records that have the same values of field has the same value in field B
Have a hard time with below, please help.
Here's the situation:
create table cord (identification NUMBER, CM VARCHAR2 (3), PM VARCHAR2 (2));
insert into string values (1, '002', 'H1');
insert into string values (2, '006', 'H1');
insert into string values (3, '004', 'H2');
insert into string values (4, '006', 'H2');
insert into string values (5, '004', 'H3');
insert into string values (6, '004', 'H3');I just need to select the folders which, for the SAME value of PM have the same value in CM, in example above, those are recordings with ID (5,6).
1 and 2 fail because for them CM and PM are different for the same H1, similar on the 3 and 4.
I don't know if this will help but records are always in 'pairs', which means that there are no cases as
7. '004' | H4
8. ' 006' | H4
9. '005' | H4
Any ideas are much appreciated.
Thank you
See if the following can help...
select id,cm,pm from( select t.* ,count(1) over(partition by cm,pm) cnt from testt t ) where cnt>1;
-
Read the nodes that have the same value as the subnodes - XML
It is more of a general JAVA / XML problem, but given that it is going into my BlackBerry app I thought I'd see if anyone knows.
Consider a simple XML document:
Whatever 1 Whatever 2 Whatever 3 Using the standard org.w3c.dom, I can get the nodes in X by the practice...
NodeList fullnodelist = doc.getElementsByTagName ("x");
But if I want to go to the next set of 'e', I try to use something like...
Element element = (Element) fullnodelist.item(0);NodeList nodes = pelement.getElementsByTagName("e");
EXPECTED back '3' nodes (because there are 3 series of 'e'), but it returns '9' - because it gets all entries including the 'e' apperently.
It would be nice in the above case, because I could probably go through and find what I'm looking for. The problem I have is that when the XML file looks like the following:
whatever Something Else whatever Something Else When I ask 'e' value, it returns 4, instead of (what I want) 2.
I am simply not understand how DOM parsing works? Generally, in the past I used my own XML documents so I name never articles like this, but unfortunately this isn't my XML file and I don't have the choice to work like this.
What I thought I would do, it is write a loop knots "drills down" so that I can combine each node...
public static NodeList getNodeList(Element pelement, String find) { String[] nodesfind = Utilities.Split(find, "/"); NodeList nodeList = null; for (int i = 0 ; i <= nodesfind.length - 1; i++ ) { nodeList = pelement.getElementsByTagName( nodesfind[i] ); pelement = (Element)nodeList.item(i); } // value of the nod we are looking for return nodeList; }
.. While if adopted you ' s/e' in the service, he would return the 2 nodes I'm looking (or elements, perhaps I'm using the wrong terminology?). on the contrary, it returns all the 'e' nodes in this node.
Anyway, if anyone is still with me and has a suggestion, it would be appreciated.
Well, there is no doubt that there is a learning curve robust for XML programming. You can take an hour or two and go through one of the tutorials that are circulating on the net. (Like that of w3schools.com.)
Basically, almost everything in XML is a node, the Document that returns the parser. The API for node tells you that you can test the node type you have by calling getNodeType, which returns one of the constants of type node (Node.ELEMENT_NODE, Node.TEXT_NODE, etc..) If necessary, you can then convert the variable to the corresponding interface (element, text, etc.).
Similarly, the API documentation say you for any node, calling getChildNodes (or for an element node or Document getElementsByTagName) will give you a NodeList (a little non-types of nodes in the XML API), while calling getFirstChild and getNextSibling to any node will give you another node (or null ).
Once you learn the API, writing logic of course is not all that hard. For example, if the only 'e' interest tags are those directly under the element root of the document (as shown in your example) you can simply go to them directly:
Vector getTopENodes(Document doc) { Vector vec = new Vector(); NodeList nodes = doc.getDocumentElement().getChildNodes(); int n = nodes.getLength(); for (int i = 0; i < n; ++i) { Node node = nodes.item(i); if (node.getNodeType() == Node.ELEMENT_NODE && "e".equals(node.getNodeName())) { vec.addElement(node); } } return vec;}
Note that this example does not assume that all children are nodes of element 'e '. the document could have comments, white space or something else that makes it into the DOM as comment, text or any other type of node.
On the other hand, if you want to capture every "e" tag which is directly under the ' tag, no matter the level, then you need to do something a little more complicated (it's on the top of my head - no guarantee):
static class NodeListImp implements NodeList { private Vector nodes = new Vector(); public int getLength() { return nodes.size(); } public Node item(int index) { return (Node) nodes.elementAt(index); } public add(Node node) { nodes.addElement(node); }} NodeList getTargetNodes(Document doc) { NodeListImp list = new NodeListImp(); getTargetnodes(list, doc.getDocumentElement(), false); return list;} void getTargetNodes(NodeListImp list, Node node, boolean parentIsS) { if (node.getNodeType() == Node.ELEMENT_NODE) { // node name is tag name for element nodes String name = node.getNodeName(); if (parentIsS && "e".equals(name)) { list.add(node); } parentIsS = "s".equals(name); for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { getTargetNodes(list, child, parentIsS); } }}
I hope that it gets the idea across.
-
How to remove the lines that have the employee name double?
Hello world
Greetings
I'm using oracle 11g.
Suppose I have a table and I want to delete lines that have the name used twice?
So given below is my table so I only delete lines that have more than one 'Ram' and 'Dilip' ename.
How to do this?
EmpID Ename salary Commission depnto 101 RAM 5000 453 1 102 RAM 6000 765 2 103 Sisi 3456 876 3 104 Dilip 7656 675 4 105 Mohan 9878 767 5 106 Dilip 5646 987 6 107 Ganesh 9823 455 7 You can use a simple code as follows
Delete From EMP
Where rowid! = (select min (rowid) of the group by Ename EMP);
For preserved older values using 'min (rowid)'
and for the most recent values required use "max (rowid)"
Thank you.
-
How to identify columns that have the same data in a SQL query or function?
Deal all,
How to identify columns that have the same data in a SQL query or function? I have the sample data as below
!DEPT_ID EMP_ID Come on CITY STATE COUNTRY 1 1 1 June 1983 DELHI HUMAN RESOURCES India 1 2 18 January 1987 DELHI HUMAN RESOURCES India 1 3 28 November 1985 DELHI HUMAN RESOURCES India 1 4 4 June 1985 DELHI HUMAN RESOURCES India 2 5 5 June 1983 MUMBAI HD India 2 6 6 June 1983 MUMBAI HD India 2 7 7 June 1983 MUMBAI HD India . 19832 8 8 Jun MUMBAI HD India . June 19833 9 9 GURGAON DL India 3 10 10 June 1983 GURGAON DL India Now, I want to Indify columns that have the same data for the same Department ID.
Is it possible in sql unique or do I have to write the function for this? Pls Help how to write?
Thanks in advance.
You can try this?
WITH T1)
DEPT_ID, EMP_ID, DATE OF BIRTH, CITY, STATE, COUNTRY
), ()
SELECT 1, 1, TO_DATE('1.) June 1983', 'JJ. LUN. (YYYY'), 'DELHI', 'HR', 'INDIA' OF THE DUAL UNION ALL
SELECT 1, 2, TO_DATE('18.) January 1987', 'JJ. LUN. (YYYY'), 'DELHI', 'HR', 'INDIA' OF THE DUAL UNION ALL
SELECT 1, 3, TO_DATE('28.) November 1985', 'JJ. LUN. (YYYY'), 'DELHI', 'HR', 'INDIA' OF THE DUAL UNION ALL
SELECT 1, 4, TO_DATE('4.) June 1985', 'JJ. LUN. (YYYY'), 'DELHI', 'HR', 'INDIA' OF THE DUAL UNION ALL
SELECT 2.5, TO_DATE('5.) June 1983', 'JJ. LUN. (YYYY'), 'BOMBAY', 'HD', 'INDIA' OF THE DUAL UNION ALL
SELECT 2.6, TO_DATE('6.) June 1983', 'JJ. LUN. (YYYY'), 'BOMBAY', 'HD', 'INDIA' OF THE DUAL UNION ALL
SELECT 2.7, TO_DATE('7.) June 1983', 'JJ. LUN. (YYYY'), 'BOMBAY', 'HD', 'INDIA' OF THE DUAL UNION ALL
SELECT 2.8, TO_DATE('8.) June 1983', 'JJ. LUN. (YYYY'), 'BOMBAY', 'HD', 'INDIA' OF THE DUAL UNION ALL
SELECT 3, 9, TO_DATE('9.) June 1983', 'JJ. LUN. (YYYY'), 'GURGAON', 'DL', 'INDIA' OF THE DUAL UNION ALL
SELECT 3.10, TO_DATE('10.) June 1983', 'JJ. LUN. (YYYY'), 'GURGAON', 'DL', 'INDIA' OF THE DOUBLE)
SELECT DEPT_ID,
RTRIM (XMLAGG (XMLELEMENT(A,VALS||',')). Extract ('//Text ()'), ',') COLUMNS_WITH_DUPLICATE
DE)
SELECT * FROM)
SELECT DEPT_ID,
EMP_ID,
Date of birth
CITY,
STATE,
COUNTRY
DE)
SELECT DEPT_ID,
EMP_ID,
Date of birth
CITY,
STATE,
COUNTRIES,
COUNT (*) OVER(PARTITION BY DEPT_ID ORDER BY EMP_ID DESC,DOB DESC,CITY DESC,STATE DESC, COUNTRY DESC) RN
DE)
SELECT DEPT_ID,
CASE WHEN(CEID>1) AND THEN 'YES' ELSE 'NO' END AS EMP_ID.
CASE WHEN(CDOB>1) THEN 'YES' ELSE 'NO' END AS DATE OF BIRTH,
CASE WHEN(CCITY>1) AND THEN 'YES' ELSE 'NO' END AS CITY.
CASE WHEN(CSTATE>1) AND THEN 'YES' ELSE 'NO' END AS STATE.
CASE WHEN(CCOUNTRY>1) THEN 'YES' ELSE 'NO' END AS A COUNTRY
DE)
SELECT DISTINCT
DEPT_ID,
CEID,
CDOB,
CITY,
CSTATE,
CCOUNTRY
DE)
SELECT DEPT_ID,
COUNT (*) TO THE CEID (DEPT_ID PARTITION, EMP_ID),.
COUNT (*) ON CDOB (DEPT_ID SCORE, DATE OF BIRTH),
COUNT (*) ON THE CITY (DEPT_ID PARTITION, CITY),
COUNT (*) ON CSTATE (DEPT_ID PARTITION, STATE).
COUNT (*) ON CCOUNTRY (DEPT_ID, COUNTRY PARTITION)
FROM T1)))
WHERE RN = 1)
UNPIVOT (CLO FOR (VALS) IN (EMP_ID, DATE OF BIRTH, CITY, STATE, COUNTRY)))
WHERE COLS = "YES".
DEPT_ID GROUP;
OUTPUT:
DEPT_ID COLUMNS_WITH_DUPLICATE
--------- ------------------------1 CITY, COUNTRY, STATE
2 CITY, COUNTRY, STATE
3 CITY, COUNTRY, STATEPost edited by: Parth272025
-
I need to convert PDF to Excel, however, the columns and tabs make many merged cells and the number of columns empty. In addition to not separate the columns properly, I see many not separate lines together in the same cell. I even think that Adobe Acrobat Pro DC has limits. There is no way to set what points in columns to force the column break? Or create several columns that are unnecessary? How column in Excel, size fixed when import us text and define where breaks have columns of text?
Google Tradutor para empresas:Google para appsTradutor sitesGlobal market Finder traducao Toolkit
Acts traducao Instantaneasobre o Google TradutorCelularComunidadePrivacidade e TermosAjudaEnviar comments
PDF does not contain columns, lines, formats, styles or other aspects of word processing or spreadsheet file formats.
This is because the PDF is decidedly not a file format of word processor or a spreadsheet or something 'like' one of these.
(see ISO 32000 for what PDF "is")
Which allows to optimize the export of the content of a page PDF is to start with that tag well formed PDF (ISO 14289-1, PDF/UA-1).
Without that export is what it is and we performs the cleanup of any necessary content using the native application for the export of files (MS Word or Excel).
Be well...
-
two elements that have the same source
Hi guys,.
I am trying to use the display on a Google Map plugin location. As I had this plugin requires two elements that have the same source:
Article 1 - A text to insert the value (address) in the database. The source of this question would be 'MAP' column.
2 - Google Map plugin ELEMENT to visualize on the map. The source of this issue should also be "Map" the column that is used to read the address.
But the problem, as you saw, we can not create a new record if we have two items with the same source. How can I get around this?
Here is the link to the plugin:
http://Apex.Oracle.com/pls/Apex/f?p=plugins:LOCATION_MAP:2943553726537511
Kind regards
Fateh
Published by: Fateh July 21, 2011 02:52Hi Fateh,
Tried the plugin you mentioned! Had a preview of your problem.
>
I am trying to use the display on a Google Map plugin location. As I had this plugin requires two elements that have the same source
>
As your form seems to be running automatic process line processing DML that will obviously give an error if you have two items
with the same source i.e. 'MAP' that is your database column.
>
Article 1 - A text to insert the value (address) in the database. The source of this question would be 'MAP' column.
>
I think that this point is already with you as you may have created form based on a Table or form and report based on a Table.
Leave the source of this article because it's IE card - the database column.
>
2 - Google Map plugin ELEMENT to visualize on the map.
>
Change the source of this article as:
Source type: static assignment (value corresponds to the source attribute)
Source of value or expression:&P1_ADDRESS.
Where P1_ADDRESS is the element:
>
Article 1 - A text to insert the value (address) in the database. The source of this question would be 'MAP' column.
>I hope that helps!
Kind regards
Kiran -
All channels to HAVE it have the same value
I use the example for a multichannel AI aiex2.cpp read with mseries NI6280 devices.
This example works for a lane, but other chains have the same value
For example: I put 5 Volt on the first string, and then the other channel are 5 Volt too.
What should I consider in the configuration?
Hello Beilei,
I think that you run in theghost of the question. The other strings that you use are connected to the earth when you connect the first channel to 5V? If the other channels are floating, they will read the same value as the first string... 5V.
Steven T.
-
All channels to HAVE it have the same value - NI PCI-6221 and NI PCI-6229
Hello
I use the aiex1.cpp example for a multi-channel read with the devices mseries 6221 and 6229.
This example works for a lane, but other chains have the same value (difference of +-0.001 Volt).
For example: I put 5 Volt on the first string, and then the other channel are 5 Volt too.
What should I consider in the configuration?
Heiko Hello!
your description looks like the effect you are having 'ghosts '.
For more information about ghost images and how to get rid of, check out these links:
http://digital.NI.com/public.nsf/allkb/73CB0FB296814E2286256FFD00028DDF?OpenDocument
and
http://digital.NI.com/public.nsf/allkb/C6C7DE575301A379862572DD00480A01?OpenDocument
Best regards
Moritz M.
-
Retruning lines which have the same return value from the function RANK
Hi, I want to achieve is to use a DENSE RANK function to identify the same value of the data, if the rank values are same then extra. Here is the code
This retrunWITH CTE AS ( SELECT SalesPersonID, SalesQuota, DENSE_RANK() OVER (ORDER BY SalesQuota DESC) as DENSE_RANK FROM Sales.SalesPersonQuotaHistory WHERE SalesQuota BETWEEN 266000.00 AND 319000.00 )
How I choose the rank value that are of the same value?SalesPersonID SalesQuota DENSE_RANK 280 319000.00 1 287 304000.00 2 280 301000.00 3 282 288000.00 4 283 284000.00 5 287 281000.00 6 278 280000.00 7 283 280000.00 7 283 267000.00 8 278 266000.00 9
The result should be278 280000.00 7 283 280000.00 7
with cte as ( select salespersonid, salesquota, dense_rank() over (order by salesquota desc) as dr from sales.salespersonquotahistory where salesquota between 266000.00 and 319000.00 ) select * from ( select cte.*, count(*) over(partition by dr) ct from cte ) where ct > 1
-
GL CCID have the same values for Segment
Is it possible that two different code_combination_id in the same GL_Code_Combination table has the same values for segment.
It is, when I run the accounts payable balance report trial of the responsibility of the PA, its follow-up of the transactions ID associated with only 1 and not both.
But, here, for the same Chart_of_Accounts_Id, we can see that there are two Code_combination_id entries, with the same values for segment.
Can you please let me know if this is possible?
For example: I'm running the following queries and Segment1, Segment2, Segment3, Segment4, 12855 CCId values Segment5 is the same as Segment1, Segment2, Segment5, Segment4, Segment3 to 13402.
Select CODE_COMBINATION_ID, CHART_OF_ACCOUNTS_ID,
SEGMENT1, SEGMENT2 SEGMENT3, SEGMENT4, ENABLED_FLAG, SEGMENT5,
* of the GL_CODE_COMBINATIONS where CODE_COMBINATION_ID = 12855
Select CODE_COMBINATION_ID, CHART_OF_ACCOUNTS_ID,
SEGMENT1, SEGMENT2 SEGMENT3, SEGMENT4, ENABLED_FLAG, SEGMENT5,
* of the GL_CODE_COMBINATIONS where CODE_COMBINATION_ID = 13402
CCID - Segment1, Segment2, Segment3, Segment4, Segment5
-----------------------------------------------------------------------------------------------
12855 01 000 2220 00000 000
13402 01 000 2220 00000 000
I hope you understand.
Thank you
BobHi Bob,
Can you please check the id of chart of accounts for the two combinations...
Concerning
MuthuPublished by: Muthu on April 30, 2013 02:10
-
The column is to summarize all the lines and display the same value in all the lines.
Hello
Please see the query below. I have a problem in this query to retrieve the abs_qty when the P:item ie setting) msib.segment1 is not given as an input parameter. His warning just to the top of the total quantity for all items. With the passage of P:item ie) msib.segment1 as an input parameter, it gets the exact value for abs_qty. kindly help me to solve this problem.
Note only: manufacturing plant, start date and end Date are Mandatory parameters (required). Others such as code point, Base model and Scheduler are optional.
SELECT mmt.transaction_date date_produced, msib.segment1 point,
CIC.cost_type_id, msib.description item_description,
MC.segment6 base_model, mc.segment7 trade_brand,
MMT.subinventory_code subinventory,
mil. Segment1 | '.' || mil. Segment2 | '.' || mil.segment3 ELECTROLUX,
OOD.organization_code
|| '-'
|| OOD.organization_name manufacturing_plant,
MMT.transaction_quantity quantity_produced,
MTT.transaction_type_name transaction_type, msib.inventory_item_id,.
MSIB.organization_id, cic.material_cost, COST,
CIC.material_overhead_cost transport, csc.standard_cost,.
* (check (NVL ((SELECT SUM (mmt.transaction_quantity) total_NET_qty *))))
OF mtl_material_transactions mmt.
mtl_system_items_b msib,
mtl_transaction_types mtt,
org_organization_definitions ood,
mtl_txn_source_types mts
WHERE mmt.organization_id = msib.organization_id
AND msib.inventory_item_id = mmt.inventory_item_id
AND mmt.transaction_type_id = mtt.transaction_type_id
AND mmt.organization_id = ood.organization_id
AND mtt.transaction_type_name = "Completion of work in PROGRESS"
AND mts.transaction_source_type_name = 'job or schedule. "
AND msib.segment1 = NVL (: p_item, msib.segment1)
AND ood.organization_code =: p_manufacturing_plant
AND BETWEEN TRUNC (mmt.transaction_date): p_start_date
AND: p_end_date), 0)
-
* (NVL ((SELECT SUM (mmt.transaction_quantity) total_NET_qty *)))
OF mtl_material_transactions mmt.
mtl_system_items_b msib,
mtl_transaction_types mtt,
org_organization_definitions ood,
mtl_txn_source_types mts
WHERE mmt.organization_id = msib.organization_id
AND msib.inventory_item_id = mmt.inventory_item_id
AND mmt.transaction_type_id = mtt.transaction_type_id
AND mmt.organization_id = ood.organization_id
AND mtt.transaction_type_name = "Ongoing work exit"
AND mts.transaction_source_type_name = 'job or schedule. "
AND msib.segment1 = NVL (: p_item, msib.segment1)
AND ood.organization_code =: p_manufacturing_plant
AND BETWEEN TRUNC (mmt.transaction_date): p_start_date
AND: p_end_date
*), 0))) abs_qty of the double) AS ABS_qtyy, * (select (NVL ((SELECT SUM (mmt.transaction_quantity) total_NET_qty
OF mtl_material_transactions mmt.
mtl_system_items_b msib,
mtl_transaction_types mtt,
org_organization_definitions ood,
mtl_txn_source_types mts
WHERE mmt.organization_id = msib.organization_id
AND msib.inventory_item_id = mmt.inventory_item_id
AND mmt.transaction_type_id = mtt.transaction_type_id
AND mmt.organization_id = ood.organization_id
AND mtt.transaction_type_name = "Completion of work in PROGRESS"
AND mts.transaction_source_type_name = 'job or schedule. "
AND msib.segment1 = NVL (: p_item, msib.segment1)
AND ood.organization_code =: p_manufacturing_plant
AND BETWEEN TRUNC (mmt.transaction_date): p_start_date
AND: p_end_date), 0)
-
(((SELECT SUM (mmt.transaction_quantity) total_NET_qty NVL
OF mtl_material_transactions mmt.
mtl_system_items_b msib,
mtl_transaction_types mtt,
org_organization_definitions ood,
mtl_txn_source_types mts
WHERE mmt.organization_id = msib.organization_id
AND msib.inventory_item_id = mmt.inventory_item_id
AND mmt.transaction_type_id = mtt.transaction_type_id
AND mmt.organization_id = ood.organization_id
AND mtt.transaction_type_name = "Ongoing work exit"
AND mts.transaction_source_type_name = 'job or schedule. "
AND msib.segment1 = NVL (: p_item, msib.segment1)
AND ood.organization_code =: p_manufacturing_plant
AND BETWEEN TRUNC (mmt.transaction_date): p_start_date
AND: p_end_date
(), 0))) abs_qty of dual) * csc.standard_cost AS abs_val
OF mtl_material_transactions mmt.
mtl_system_items_b msib,
mil mtl_item_locations
mtl_transaction_types mtt,
org_organization_definitions ood,
mtl_txn_source_types mts,
MC mtl_categories,
mtl_item_categories mic,
MCS mtl_category_sets,
cst_item_costs cic,
cst_standard_costs csc,
cst_cost_types ct,
mfg_lookups OLM
WHERE mmt.organization_id = msib.organization_id
AND msib.inventory_item_id = mmt.inventory_item_id
AND mmt.locator_id = mil.inventory_location_id
AND mil.organization_id = msib.organization_id
AND mil.subinventory_code = mmt.subinventory_code
AND mmt.transaction_type_id = mtt.transaction_type_id
AND msib.organization_id = ood.organization_id
AND mic.category_set_id = mcs.category_set_id
AND mc.category_id = mic.category_id
AND mc.structure_id = mcs.structure_id
AND mic.inventory_item_id = msib.inventory_item_id
AND mic.organization_id = msib.organization_id
AND mcs.category_set_id = 52487965
AND msib.inventory_item_id = cic.inventory_item_id
AND msib.organization_id = cic.organization_id
AND ct.cost_type_id = cic.cost_type_id
AND cic.organization_id = ood.organization_id
AND mil.inventory_location_id = mmt.locator_id
AND mmt.transaction_source_type_id = mtt.transaction_source_type_id
AND mmt.transaction_action_id = mtt.transaction_action_id
AND mmt.transaction_source_type_id = mts.transaction_source_type_id
AND mmt.transaction_action_id = mlo.lookup_code
AND mmt.inventory_item_id = csc.inventory_item_id
AND mmt.organization_id = csc.organization_id
AND csc.last_update_date > =.
(SELECT MAX (csc1.last_update_date)
OF cst_standard_costs csc1
WHERE csc1.inventory_item_id = mmt.inventory_item_id
AND csc1.organization_id = mmt.organization_id)
AND msib.segment1 = NVL (: p_item, msib.segment1)
AND NVL (mc.segment6, 'X') = NVL (: p_base_model, NVL (mc.segment6, 'X'))
AND = NVL (msib.planner_code, 'Y')
NVL (: p_planner_code, NVL (msib.planner_code, 'Y'))
AND SUPERIOR (mlo.meaning) = "COMPLETION of the ASSEMBLY.
AND mtt.transaction_type_name = "Completion of work in PROGRESS"
AND ct.cost_type = 'Frozen '.
AND mts.transaction_source_type_name = 'job or schedule. "
AND ood.organization_code =: p_manufacturing_plant
AND BETWEEN TRUNC (mmt.transaction_date): p_start_date AND: p_end_dateIf abs_qty and, accordingly, abs_val must not be the same for all rows returned, you will need to rewrite your query so that the abs_qty will not be calculated (separately) in isolation without interaction with the data in the main table list.
Your query is treated the same as below (note the changed table alias by adding numbers to the original of yours)SELECT mmt.transaction_date date_produced, msib.segment1 item, cic.cost_type_id, msib.description item_description, mc.segment6 base_model, mc.segment7 trade_brand, mmt.subinventory_code subinventory, mil.segment1 || '.' || mil.segment2 || '.' || mil.segment3 LOCATOR, ood.organization_code || '-' || ood.organization_name manufacturing_plant, mmt.transaction_quantity quantity_produced, mtt.transaction_type_name transaction_type, msib.inventory_item_id, msib.organization_id, cic.material_cost COST, cic.material_overhead_cost freight, csc.standard_cost, (select (NVL( (SELECT SUM (mmt1.transaction_quantity) total_NET_qty FROM mtl_material_transactions mmt1, mtl_system_items_b msib1, mtl_transaction_types mtt1, org_organization_definitions ood1, mtl_txn_source_types mts1 WHERE mmt1.organization_id = msib1.organization_id AND msib1.inventory_item_id = mmt1.inventory_item_id AND mmt1.transaction_type_id = mtt1.transaction_type_id AND mmt1.organization_id = ood1.organization_id AND mtt1.transaction_type_name = 'WIP Completion' AND mts1.transaction_source_type_name = 'Job or Schedule' AND msib1.segment1 = NVL (:p_item, msib1.segment1) AND ood1.organization_code = :p_manufacturing_plant AND TRUNC (mmt1.transaction_date) BETWEEN :p_start_date AND :p_end_date ),0 ) - NVL( (SELECT SUM (mmt2.transaction_quantity) total_NET_qty FROM mtl_material_transactions mmt2, mtl_system_items_b msib2, mtl_transaction_types mtt2, org_organization_definitions ood2, mtl_txn_source_types mts2 WHERE mmt2.organization_id = msib2.organization_id AND msib2.inventory_item_id = mmt2.inventory_item_id AND mmt2.transaction_type_id = mtt2.transaction_type_id AND mmt2.organization_id = ood.2organization_id AND mtt2.transaction_type_name = 'WIP Issue' AND mts2.transaction_source_type_name = 'Job or Schedule' AND msib2.segment1 = NVL (:p_item, msib2.segment1) AND ood2.organization_code = :p_manufacturing_plant AND TRUNC (mmt.2transaction_date) BETWEEN :p_start_date AND :p_end_date ),0 ) ) abs_qty from dual ) AS ABS_qtyy, (select (NVL( (SELECT SUM (mmt3.transaction_quantity) total_NET_qty FROM mtl_material_transactions mmt3, mtl_system_items_b msib3, mtl_transaction_types mtt3, org_organization_definitions ood3, mtl_txn_source_types mts3 WHERE mmt3.organization_id = msib3.organization_id AND msib3.inventory_item_id = mmt3.inventory_item_id AND mmt3.transaction_type_id = mtt3.transaction_type_id AND mmt3.organization_id = ood3.organization_id AND mtt3.transaction_type_name = 'WIP Completion' AND mts3.transaction_source_type_name = 'Job or Schedule' AND msib3.segment1 = NVL (:p_item, msib3.segment1) AND ood3.organization_code = :p_manufacturing_plant AND TRUNC (mmt3.transaction_date) BETWEEN :p_start_date AND :p_end_date ),0 ) - NVL( (SELECT SUM (mmt4.transaction_quantity) total_NET_qty FROM mtl_material_transactions mmt4, mtl_system_items_b msib4, mtl_transaction_types mtt4, org_organization_definitions ood4, mtl_txn_source_types mts4 WHERE mmt4.organization_id = msib4.organization_id AND msib4.inventory_item_id = mmt4.inventory_item_id AND mmt4.transaction_type_id = mtt4.transaction_type_id AND mmt4.organization_id = ood4.organization_id AND mtt4.transaction_type_name = 'WIP Issue' AND mts4.transaction_source_type_name = 'Job or Schedule' AND msib4.segment1 = NVL (:p_item, msib4.segment1) AND ood4.organization_code = :p_manufacturing_plant AND TRUNC (mmt4.transaction_date) BETWEEN :p_start_date AND :p_end_date ),0 ) ) abs_qty from dual ) * csc.standard_cost AS abs_val FROM mtl_material_transactions mmt, mtl_system_items_b msib, mtl_item_locations mil, mtl_transaction_types mtt, org_organization_definitions ood, mtl_txn_source_types mts, mtl_categories mc, mtl_item_categories mic, mtl_category_sets mcs, cst_item_costs cic, cst_standard_costs csc, cst_cost_types ct, mfg_lookups mlo WHERE mmt.organization_id = msib.organization_id AND msib.inventory_item_id = mmt.inventory_item_id AND mmt.locator_id = mil.inventory_location_id AND mil.organization_id = msib.organization_id AND mil.subinventory_code = mmt.subinventory_code AND mmt.transaction_type_id = mtt.transaction_type_id AND msib.organization_id = ood.organization_id AND mic.category_set_id = mcs.category_set_id AND mc.category_id = mic.category_id AND mc.structure_id = mcs.structure_id AND mic.inventory_item_id = msib.inventory_item_id AND mic.organization_id = msib.organization_id AND mcs.category_set_id = 52487965 AND msib.inventory_item_id = cic.inventory_item_id AND msib.organization_id = cic.organization_id AND ct.cost_type_id = cic.cost_type_id AND cic.organization_id = ood.organization_id AND mil.inventory_location_id = mmt.locator_id AND mmt.transaction_source_type_id = mtt.transaction_source_type_id AND mmt.transaction_action_id = mtt.transaction_action_id AND mmt.transaction_source_type_id = mts.transaction_source_type_id AND mmt.transaction_action_id = mlo.lookup_code AND mmt.inventory_item_id = csc.inventory_item_id AND mmt.organization_id = csc.organization_id AND csc.last_update_date >= (SELECT MAX (csc1.last_update_date) FROM cst_standard_costs csc1 WHERE csc1.inventory_item_id = mmt.inventory_item_id AND csc1.organization_id = mmt.organization_id ) AND msib.segment1 = NVL (:p_item, msib.segment1) AND NVL (mc.segment6, 'X') = NVL (:p_base_model, NVL (mc.segment6, 'X')) AND NVL (msib.planner_code, 'Y') = NVL (:p_planner_code, NVL (msib.planner_code, 'Y')) AND UPPER (mlo.meaning) = 'ASSEMBLY COMPLETION' AND mtt.transaction_type_name = 'WIP Completion' AND ct.cost_type = 'Frozen' AND mts.transaction_source_type_name = 'Job or Schedule' AND ood.organization_code = :p_manufacturing_plant AND TRUNC (mmt.transaction_date) BETWEEN :p_start_date AND :p_end_date
Concerning
Etbin
-
How to determine how many times result set have the same value
HI -.
I do a report that will be used for the analysis of trends in payment.
My initial result set looks like this:
(number of lines, of course, pivot table result set)HOUSEHOLD_ID JAN_PMT FEB_PMT MAR_PMT APR_PMT MAY_PMT JUN_PMT JUL_PMT AUG_PMT SEP_PMT OCT_PMT NOV_PMT DEC_PMT 90026845409 1 1 1 1 2 1 1 1 1 0 1 0
I need to determine the households that have a value > 0 in three or more consecutive months.
I hope that someone will have some suggestions because that the only solutions I come up with right now would be a nightmare of coding (lots of "GOLD"), and I assume (hope) there's a better solution out there.
Thank you!
ChristineIf you are limited to only 12 months I would use GOLD in conjunction with the sign function.
sign of a positive number returns 1
sign of 0 returns 0
sign of a negative number returns - 1Really, it doesn't look like bad lto for me. Obviously if you have a numbe rof months variable must be a different solution.
with the data
as
(
Select hh '90026845409', 1 jan, Feb 1, 1 March, 1 April, 2 may, 1 June, 1 July, August 1, 1 sep, oct, 1 nov, dec double 0 0
)
Select * from data
where
(sign (jan) sign (feb) + sign (mar)) = 3
or
Sign (Feb) + Sign (Tue) + Sign (APR) = 3
...
or
Sign (Oct) + Sign (Nov) + Sign (DEC) = 3 -
report that shows the same values twice in 11g
Hi am in report form of oracle 11g I have a report that lists 5 rows, the problem is the same elpse of data on the second page, how do I fix that the request is ok when I run with sql developer, it shows the record 5, the problem is when I run the report he show the same data in multiple pages
for example
Page 1
employeeno employeeename
Sharon 20000
Peter 20001
page 2
employeeno employeeename
Sharon 20000
Peter 20001
You have an extensible framework around your main frame? For example, when the requirement is to have 2 copies could have a fake request for an extensible framework around your main frame:
Select 1 as a double
Union of all the
Select 2 double
Maybe you are looking for
-
PC Backup in the iMac desktop folder
Hi all. I need help any iMac user who also have a Win10 PC, who has resolved to support problem until Win10 a folder on the desktop iMac computer. Yes maybe that's a problem of Win10 sending data, but I'm looking for help in case it comes to Mac dat
-
Qosmio F30 - manual says max RAM is 2 GB
I see that other members of the forum have improved their F30 to 4 GB of RAM. However, the manual indicates the recognized maximum memory (page 20 in mine), is only 2 GB. Even if the F30 can recognize 4 GB of RAM if necessary he may not be able use i
-
Satellite L10-117: the fan stops and only run at full speed
I L10 - 117 with celeron M 370, my fan works for about 2 minutes and stop after only 2-5 minutes, it starts again at full speed. It only works at full speed (made a lot of noise) or stop, I noticed that my friends toshiba satellite fan (also celeronM
-
Uninitialized external hard drive
I'm having a problem with my external hard drive and tried to solveit. I installed the USB HD a year ago and he ran a lot. Since I'm on a large number of USB devices, I decided to hook a USB hub and then installed a USB wireless device. When I did, I
-
Failure of group and multi-member node?
If you have a group of several Member, with a storage pool, and a table fails, you would not lose all your data because it is written in any of the tables? Thank you She