Need Query to Calcute number of Polygins

Hi All,
I have a problem trying to figure out solve the below problem :
I have one table which contains informations about lot nos. The table is as below : TABLE A
PROJECT_ID MKTS_IND MKTS_NO LOT_NO
14223 MK 17 00102X
15213 MK 17 00102X
47299 MK 17 00102X
46911 MK 25 98095N
2446 MK 25 98095N
I have another table which has all the polygons which a project belongs to as below : TABLE B
PROJECT_ID POLYGON_ID
2446 MK25B156
14223 MK17B426
15213 MK17C016
46911 MK25B157
47299 MK17B424
The first requirement is to get all the LOT NO which are having more than one polygon ,
e.g
From Table A MKTS_IND+MKTS_NO+'-'+LOT_NO(=MK17-00102X) should be selected if it is in TABLE B with more than one POLYGON_ID. ( Note . More than one project id need not mean it is in multiple POLYGON_ID )
Now the more complex part .
I have another table which is as below : TABLE C
PARENT_LOT_NO CHILD_LOT_NO
MK02-01368N MK02-02431N
MK02-01369X MK02-02902A
MK02-01370K MK02-02892A
We need to match from TABLE A MKTS_IND+MKTS_NO+'-'+LOT_NO(=MK17-00102X) with the CHILD_LOT_NO and get the PARENT_LOT_NO and using this parent lot no we need to count the number of polygons that this parent lot number belongs. There can be many parent lot numbers for this.
For each parent lot no found we need to go back again in TABLE C and match with the CHILD_LOT_NO and loop through the parent lot no to count the number of polygons for each parent .
As an example :
Lets say i have MK17-00102X from TABLE A . I will select the PARENT_LOT_NO from TABLE C where CHILD_LOT_NO=MK17-00102X.
Loop through ALL the Parent Lot Nos found . Lets say I found two parent lot numbers for this : MK17-1111A AND MK17-1111B
I will need to calculate the number of polygons for MK17-1111A and MK17-1111B .
I will then need to go to TABLE C and get PARENT LOT NO's for MK17-1111A and MK17-1111B and calculate the number of polygon for these new parent lot numbers.
Please let me know if there is any easy way to do the job or we need to write PL/SQL procedure for this.
I have tried to make the requirement as clear as possible.
Thanks for your time and effort on this..
Regards
Ravinder
Edited by: user10934487 on Jul 4, 2010 9:12 PM
Edited by: user10934487 on Jul 4, 2010 9:21 PM

Hi, Ravinder,
Whenever you have a question, please post CREATE TABLE and INSERT statements for a little sample data, and the results you want from that data. Without that, it's hard to understnd what you want, and impossible to test solutions.
If you want a solution that works in your version of Oracle, then say what version that is.
I think this is what you want fro the first problem:
SELECT       a.mkts_ind,  a.mkts_no,  a.lot_no
FROM       a
JOIN       b     ON     a.mkts_ind ||
               a.mkts_no  ||
               '-'        ||
               a.lot_no     = b.polygon_id
GROUP BY  a.mkts_ind,  a.mkts_no,  a.lot_no
HAVING       COUNT (b.polygon_id)     > 1
ORDER BY  a.mkts_ind,  a.mkts_no,  a.lot_no
;For the second (more complex) problem, I think you want a CONNECT BY query. I don't think you need PL/SQL, but without the exact data and results, I'm just guessing.

Similar Messages

  • Query to get number of invoice created by user between from and to date

    Dear All
    I need Query to get number of invoice created by user on day and his orgainization between from and to date.
    thanks

    select count(*) from ap_invoices_all where created_by = :p_User_id
    and trunc(creation_date) between :p_from_date and :P_to_date;
    Thanks/SRK

  • Access Web App - Need some advice with query (text to number problem)

    In an Access Web App I want to create a query.
    I have two tables which are related but in a bit complicated way. For some reason I have a text field in which I save a number. This number relates to the ID of another table. When I combine these two tables in a query, it's not working because the textfield
    cannot query the (ID)number field.
    Is there a way, in this query so that I covert the text field to a number so the query will work?
    I tried to do it with the "Parse" function but no luck, so far.
    Thanks, Mike

    Hi Mike,
    Based on the description, you want to create a query by joining a text filed with number filed?
    Did I understood correctly? If so, as far as I test, it works in Access 2013 web app. Here is the screen shot for your reference:
    If I misunderstood, please feel free to let me know.
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Need query to find out whether exactly 2 columns are used in any index ?

    Suppose i have two columns ID and Status (or any number of columns ) belongs to table customer...
    Now I want to create below index
    Ex. create index test1 on customer (ID , Status )
    But before creating this index i want to check that whether there is already index on these 2 columns ? May be by other name ?
    Need query for this.
    Plz help.

    Hi Shubhangi,
    Your requirement is very difficult to fulfill , i have made an attempt to replicate your reqrmnt & write a query wherein you need to compromise on few things , let us see if it works for you
    Supply table_name/owner & Number of column on which you want to find indexes
    e.g.
    select distinct INDEX_NAME,column_name
    from dba_ind_columns
    where index_name in (select distinct index_name
    from dba_ind_columns
    where table_name='&table_name'
    and table_owner='&owner'
    having count(column_name)=&column_count group by index_name);
    Enter value for table_name: ADDRESS
    Enter value for owner: ASAP
    Enter value for column_count: 2
    INDEX_NAME COLUMN_NAME
    FKIDX_AD__SF_ST_FO SF_STRUC_FORMAT_NM
    FKIDX_AD__SF_ST_FO SF_TYPE_NM
    SQL> /
    Enter value for table_name: ADDRESS
    Enter value for owner: ASAP
    Enter value for column_count: 3
    INDEX_NAME COLUMN_NAME
    FKIDX_AD__SF_ST_FO_1 POSTAL_CD
    FKIDX_AD__SF_ST_FO_1 SF_STRUC_FORMAT_NM
    FKIDX_AD__SF_ST_FO_1 SF_TYPE_NM
    Thanks,
    Ajay More
    http://moreajays.blogspot.com

  • I need a purchase order number immediately option in I-proc

    Hello,
    I created one catalog requisition in I-Proc, and checked " I need a purchase order number immediately" option during checkout. This requisition has been created and i even got message that "Purchase order number 45 has been reversed for you" With this being said...
    1. Where can i see this PO number ( I approved above requisition, but i can not see this PO number in PO screen)...?
    2. What does this purchase order number do?
    Thanks
    Deepak

    Hi Depak,
    Please check this doc...
    PO Create Documents
    Workflow File Name: poxwfatc.wft
    This workflow manages the automatic creation of purchasing documents. The PO Create Documents workflow starts in Oracle iProcurement when you submit a
    requisition associated with an existing blanket purchase agreement, contract purchase agreement, or catalog quotation in Oracle Purchasing. Customize the attributes in this workflow to fit your business needs.
    The following table shows the attributes that you must consider:
    1) Is Automatic Creation Allowed?
    Please change to Y
    AUTOCREATE_DOC Indicator (Y for Yes or N for No) of whether this workflow is initiated for all approved requisition lines.
    Default value: N
    2) Is Automatic Approval Allowed?
    AUTO_APPROVE_DOC Indicator of whether the purchase order approval workflow is initiated automatically after this workflow.
    Default value: N
    Please change to Y
    3) Should Workflow Create The Release?
    CONT_WF_FOR_AC_REL_GEN Indicator of whether this workflow creates, releases, or leaves them to the buyer to create using AutoCreate in Oracle Purchasing.
    Default value: N
    Please change to Y
    You can verify the changes through below query..
    select rtrim(w.name) name,
    w.text_default Value,
    rtrim(w.item_type) item_type
    from wf_item_attributes w
    where w.NAME in ('AUTO_APPROVE_DOC', 'CONT_WF_FOR_AC_REL_GEN', 'AUTOCREATE_DOC')
    Hope this will help.
    Regards,
    S.P DASH
    Another quick question to you, you mentioned UNSPENT code in your queries.. I think it should be UNSPSC code...correct me if I am wrong here..

  • Need Query for empty partitions

    I am having nearly 700 partitions for a table.Now i want to find out only the empty partitions.I need query for that.
    Thankx..

    Not the most elegant solution, but it works:
    declare
    rc number;
    str varchar2(200);
    begin
    for i in (select table_owner, table_name, partition_name from dba_tab_partitions) loop
    str := 'select count(*) from ' || i.table_owner || '.' || i.table_name || ' partition (' || i.partition_name || ')';
    execute immediate str into rc;
    if rc = 0 then
    dbms_output.put_line(i.table_owner || '.' || i.table_name);
    end if;
    end loop;
    end;

  • Need to find common number

    Need to find common number among the set of calls :
    Create table call (id number(15) primary key not null , mobile_number number(10), other_party number(10), call_type varchar2(10),call_date_time date, duration number(15));
    insert into call values(1,9818764535,9899875643,'IN',to_date('24-APR-13 02:10:43','dd-MON-yy hh24:mi:ss'),10);
    insert into call values(2, 9897451236,9899875643,'OUT',to_date('28-APR-13 08:11:13','dd-MON-yy hh24:mi:ss'),20);
    insert into call values(3, 9899917277,9899875643,'IN',to_date('30-APR-13 18:07:02','dd-MON-yy hh24:mi:ss'),30);
    insert into call values(4,9818764535,9215478213,'IN',to_date('01-MAY-13 02:11:13','dd-MON-yy hh24:mi:ss'),40);
    insert into call values(5, 9899917277,9215478213,'IN',to_date('01-MAY-13 08:17:02','dd-MON-yy hh24:mi:ss'),25);
    insert into call values(6, 9897451236,9012451785,'OUT',to_date('01-MAY-13 20:21:04','dd-MON-yy hh24:mi:ss'),67);
    Query criteria :
    common caller for list of numbers who is in contact with listed numbers .
    Input Mobile_number:
    9818764535
    9897451236
    9899917277
    output common number
    Mobile number  otherparty date_time duration
    9818764535 9899875643 24-APR-13 02:10:43 10
    9897451236 9899875643 28-APR-13 08:11:13 20
    9899917277 9899875643 30-APR-13 18:07:02 30

    Thanks , it helped
    But if internal calls among these mobile numbers are to be find then
    insert into call values(1,9818764535,9899875643,'IN',to_date('24-APR-13 02:10:43','dd-MON-yy hh24:mi:ss'),10);
    insert into call values(2, 9897451236,9899875643,'OUT',to_date('28-APR-13 08:11:13','dd-MON-yy hh24:mi:ss'),20);
    insert into call values(3, 9899917277,9899875643,'IN',to_date('30-APR-13 18:07:02','dd-MON-yy hh24:mi:ss'),30);
    insert into call values(4,9818764535,9215478213,'IN',to_date('01-MAY-13 02:11:13','dd-MON-yy hh24:mi:ss'),40);
    insert into call values(5, 9899917277,9215478213,'IN',to_date('01-MAY-13 08:17:02','dd-MON-yy hh24:mi:ss'),25);
    insert into call values(6, 9897451236,9012451785,'OUT',to_date('01-MAY-13 20:21:04','dd-MON-yy hh24:mi:ss'),67);
    insert into call values(7,9818764535,9897451236,'IN',to_date('02-MAY-13 22:10:43','dd-MON-yy hh24:mi:ss'),100);
    insert into call values(8, 9899917277,9818764535,'IN',to_date('02-MAY-13 23:07:02','dd-MON-yy hh24:mi:ss'),130);
    Input Mobile_number:
    9818764535
    9897451236
    9899917277
    output internal calls :
    Mobile number otherparty call_type date_time duration
    9818764535 9897451236 IN 02-MAY-13 22:10:43 100
    9899917277 9818764535 IN 02-MAY-13 23:07:02 130

  • Query to know number of executions of one day

    Hi,
    i need a query to get number of executions of the sql per day

    What database version ?
    You mean there is one sql statement you want to check daily executions ? Does it have the same sql ID each time ? If so then you could select from v$sql / v$sqlarea every 24 hours and compare counts from the previous runtime.
    Are you collecting statspack and awr snaps ? If so then you may be able to run a report to view executions in 24 hour periods.

  • My computer crashed and I need a new serial number.  I have my product key

    My computer crashed and I need a new serial number.  I have my product key

    Duplicate thread http://forums.adobe.com/thread/1204907

  • Triing to send pictures threw e mail but it tells me I need a sender verification number. What is it

    I am triing to send pictures threw eliments 9 and it tells me I need a sender verification number. What is it and where do I find it?

    Hey,
    Just to elaborate, as you have added the email id after selecting Adobe email services. You will get an email from '[email protected]'. In this mail there will be an alphanumeric code. This is the verification code asked by Organizer. If this email is not in the inbox then check your spam folder.
    ~Andromeda

  • Need to make serial number in rdf

    need to make serial number column in report builder
    i tried to put rownum as column in the select statement but data wasnot fetched probably

    user513954 wrote:
    need to make serial number column in report builder
    i tried to put rownum as column in the select statement but data wasnot fetched probablyWhat do you mean by "was not fetched properly"? Why did not rownum work for you? Do you have the corresponding SQL?
    Cheers
    Sarma.

  • Query to know number of columns in a table

    please can anyone suggest me a query to know number of columns in a table i.e.
    if I want to know how many number of colums are present in a specific table then what would be the query
    Message was edited by:
    user625519

    Give this a shot:
    SELECT table_name,count(*) as "# of Columns"
    FROM dba_tab_cols
    WHERE table_name = <table name>
    GROUP BY table_name
    ORDER BY table_name;There are other views as well such as USER_TAB_COLS and ALL_TAB_COLS.
    HTH!

  • Help needed- Reg: Display page number in SQL Reports

    Hi,
    I need to display page number in " page no: X of Y " format where X is current page & Y is total number of pages. Now I am able to display only the current page using ' sql.pno '. but not able to display in ' X of Y ' format.
    Any inputs in this regard will be helpful.
    Thanks & Regards,
    Anilkumar.

    Hello Anil,
    If you have the above requirement for Oracle Reports then follow the steps:
    1.In the Paper Layout view or Paper Design view, choose InsertPage Number.
    2. In the Insert Page Number dialog box, choose from the list the location for the page number.
    3.Click the desired page number format: Page Number Only or Page Number and Total Pages.
    Cheers,
    Suresh

  • Need query to find rows

    hi
    i need query to find out for one perticular row from parent table ,,which references how many rows in how many child tables , and child to child tables. in herirachy fashion.
    if anybody know please help me

    I guess it would be difficult to come up with a generic script to get answer that can help in all situations...you have to see the table definitions in your schema and try...like in case of emp and dept table,
    select * from dept where deptno in
    (select deptno,count(*) from emp group by deptno having count(*)>1)
    (this gives rows from dept table where , for corresponding deptno there are more than one rows in emp table).
    Thanks
    Nirav

  • We need to derive ZNUMPACK (Number of Packages) in plants depends batch

    Hi Experts,
    I have the code,it is nothing but a lookup on 0BATCH for quantity more lines greater than zero.I would like to derive it directly in the BEx Report.  That is all we have to do is count the number of batch lines.  We need to derive ZNUMPACK (Number of Packages) in plant depends upon batch. I tried it by using exceptional aggregation and tried in lot of ways. But I am not getting the solution.Please help me to solve this problem...
    Thanks,
    SVS

    Hi Amit,
      Thanks for your reply. In this scenario configurable material is involved. And first Make to Stock scenario is executed to check any material with customer entered characteristics are avialable. If its so it will determine its batch and assigned the quantity.
    If zero quantity is assigned or no quantity is assigned then I have to trigger the Make to Order scenario for rest of unconfirmed quantities in order.
    I have check it in USEREXIT_MOVE_FIELD_TO_VBAP but it was of no use. I even tried in USEREXIT_CHECK_VBAP but still no result. I am not sure what all the tables and structures i need to populate there.
    Regards,

Maybe you are looking for

  • Adobe Reader crashing when loading inside web browser?

    Hi there, Having a very frustrating problem with adobe reader XI inside google chome. Every time I open a .pdf inside the browser it just hangs? I can see it start to load (in that I see the circle turning) but it never loads. Please help! Sam

  • Default pdf files to Adobe Reader not Preview

    Pdf files always open in Preview. How can I tell my system to open them in Adobe Reader?

  • NI website on a CD?

    Hi! Are some (or all) areas of NI website available on a CD? I am specially interested links that grow from this page onwards: http://zone.ni.com/devzone/devzone.nsf/webcategories/2E4161187E3DEB30862568660020BCC8 The info here is biblical for a learn

  • Headset option missing in Enhancement settings of ...

    although i upgraded my firmware,the headset setting is still missing.only charger setting is there.can somebody help me,i'm already fed up with this model!!

  • What can I do....desperate!!!!!

    Below is the text of my feedback to Apple. I have always used Apple products and have upgraded my machines to the newest ones every couple of years. I now have a problem that puts the whole experience with Apple in serious doubt. All I am looking for