Need a SQL Query (URGENT)

Hi Folks,
I have 2 tables, in which the 1st one has 200 columns and 2 table had 2 columns.. There is one common column for both the tables, but there is little change in schema of the tables...The common col in 2nd table is a primary key but the same column in the 1st table is a ordinary one..The data type for the common column is same...
Now i need to write a query to select 199columns(except the common column)from the 1st table and the other column(2nd col)other than the common column frm the 2nd table for "table1.commoncolumn=table2.commoncolumn"......
I had tried the natural join but its nt working in my informix sql database....I also tried by explicitly mentioning column names like "select column1,column2....column199,table2.column2 from table1,table2 where table1.commoncolumn=table2.commoncolumn", but its having a severe performance impact.......
Can some please suggest a query for the above one?? Thankx in advance..

Please gimme possible solutions & suggestions regarding the above query....
The informix z forum very slow...The problem is, you labeled your questions badly. As this is a forum of volunteers people tend to react badly to the use of the word "urgent" in the subject line. Nobody's question matters more than anybody else's. In fact some regulars won't answer questions with "urgent" in the strapline as a matter of principle.
Then when we get to actually read your question it turns out to be a question about Informix. I guess not many people here use Informix so your potential pool of responders is pretty small (for instance I'm not even sure how to spell it).
It's not our fault the Informix forums are so lame.
Anyway, what I suggest is you repost your question with a new title: (Off topic) Need help with an INFORMIX query.
At least that will attract people who might be able to answer your question. Then you need to include the actual query you're running and all the supporting details necessary for people to understand the nature of the performance impact.
You need to ask the right people and you need to ask the right question. This is standard etiquette (and indeed common sense) regardless of which forum you're using.
Cheers, APC
Blog : http://radiofreetooting.blogspot.com/

Similar Messages

  • Need sql query or pl/sql query urgent

    Hi Experts,
    The requirement is that
    SELECT 'N' flag, sysdate init_date,
    '' vendor_name,
    DECODE (pa.address_type,
    'P', 'Present Address',
    'R', 'Permanent Address',
    pa.address_type
    ) address_type,
    pa.address_line1
    || ','
    || pa.address_line2
    || ','
    || pa.town_or_city
    || ','
    || meaning
    || ','
    || pa.POSTAL_CODE "Address",
    TRUNC (TO_CHAR (pa.date_from, 'YYYY')) YEAR,
    TO_CHAR (pa.date_from, 'MON') MONTH,''station
    FROM per_addresses pa, fnd_lookup_values, per_all_people_f pf
    WHERE (pf.employee_number = :1 or pf.APPLICANT_NUMBER = :2)
    and pf.EFFECTIVE_END_DATE='31-DEC-4712'
    AND pa.person_id = pf.person_id
    AND pa.business_group_id = 42
    --AND pa.date_to IS NULL
    AND lookup_type = 'PER_US_COUNTRY_CODE'
    AND lookup_code = pa.country
    AND enabled_flag = 'Y'
    AND (end_date_active IS NULL OR end_date_active > SYSDATE)
    if i run the above query the output is coming like that
    Present Address |     Flat No. 1201, OC - 15, Orange County, Plot No. GH - 4,Ahinsa Khand 1st, Indrapuram,Ghaziabad,India,201010|     2,010|     JUL
    Permanent Address |     Q.No. 354, Sector - 3 / B,,Bokaro Steel City,India,827003     |2,010     |JUL
    Present Address |     4, Sitara,Chandra Reddy layout, S.T. Bed,Bangalore,India,0|     2,006|     JAN
    Present Address |     101,,Ushma Urja Apartments,Noida,India,201301 |     2,006 |     JUL
    Permanent Address |     F-19, Maccon Colony, Opp. DAV Shyamali School,,Ranchi,India,834002 |     2,009 |     FEB
    Present Address |     Flat no. 604, B - 1, Krishna Apra Gardens,Vaibhav Khand, Plot - 7,Ghaziabad,India,201010 |     2,009     FEB
    But the requirement is the output should come like that
    Permanent Address     |Q.No. 354, Sector - 3 / B,,Bokaro Steel City,India,827003|     2,010     |JUL                    
    Permanent Address 1|     F-19, Maccon Colony, Opp. DAV Shyamali School,,Ranchi,India,834002|     2,009 |     FEB
    Present Address |     Flat No. 1201, OC - 15, Orange County, Plot No. GH - 4,Ahinsa Khand 1st, Indrapuram,Ghaziabad,India,201010|     2,010 |     JUL                    
    Present Address 1 |     Flat no. 604, B - 1, Krishna Apra Gardens,Vaibhav Khand, Plot - 7,Ghaziabad,India,201010|     2,009 |     FEB                    
    Present Address 2 |     101,,Ushma Urja Apartments,Noida,India,201301|     2,006|     JUL     
    Present Address 3 |     4, Sitara,Chandra Reddy layout, S.T. Bed,Bangalore,India,0 |     2,006|     JAN     
    Please provide logice how i need to write a sql query or procedure or function or package
    Thanks & Regards
    Venu

    You can use analytics here :
    SELECT
        flag,
        init_date,
        vendor_name,
        address_type   ||' ' ||rn AS address_type,
        Address,
        YEAR,
        MONTH,
        station
    FROM
            SELECT
                'N' flag,
                sysdate init_date,
                '' vendor_name,
                DECODE (pa.address_type, 'P', 'Present Address', 'R','Permanent Address', pa.address_type ) address_type,
                row_number() over(partition BY pa.address_type order by 1) AS rn,
                pa.address_line1
                || ','
                || pa.address_line2
                || ','
                || pa.town_or_city
                || ','
                || meaning
                || ','
                || pa.POSTAL_CODE "Address",
                TRUNC (TO_CHAR (pa.date_from, 'YYYY')) YEAR,
                TO_CHAR (pa.date_from, 'MON') MONTH,
                '' station
            FROM
                per_addresses pa,
                fnd_lookup_values,
                per_all_people_f pf
            WHERE
                    pf.employee_number  = :1
                 OR pf.APPLICANT_NUMBER = :2
            AND pf.EFFECTIVE_END_DATE='31-DEC-4712'
            AND pa.person_id         = pf.person_id
            AND pa.business_group_id = 42
                --AND pa.date_to IS NULL
            AND lookup_type  = 'PER_US_COUNTRY_CODE'
            AND lookup_code  = pa.country
            AND enabled_flag = 'Y'
            AND
                    end_date_active IS NULL
                 OR end_date_active  > SYSDATE
        );

  • Need a SQL query(Pls Its urgent)

    Hi,
    I want a SQL query for the foll..
    Details r below..
    Table AFPFTRAN
    BU TRansactiondate Amt
    13202 10-04-05 10,000
    13203 11-05-05 20,000
    13202 20-04-05 5,000
    Table AFGENCOD
    BU Clerk Name Clerk Code
    13202 Amit TFBG
    13203 Anand TFMG
    I want a query to get data as below..
    Tr Date TFBG TFMG
    Apr 15,000 0
    May 0 20,000
    JUn 0 0
    Jul 0 0
    Aug
    Sep
    Aug
    Nov
    DEc
    Jan
    Feb
    Mar
    I want this to achieve using a single query...?How can I achive this?
    Pls give the sol...
    Adios...
    Prashanth Deshmukh

    Does it look like you need ?
    SQL> select * from t;
            BU TDATE           AMT
         13202 10.04.05      10000
         13203 11.05.05      20000
         13202 20.04.05       5000
    SQL> select * from t1;
            BU NAME  CODE
         13202 Amit  TFBG
         13203 Anand TFMG
    SQL> SELECT pivot_month.mname, tops.TFBG, tops.TFMG
      2  from
      3  (
      4  select to_char(t.tdate,'MM') month_no,
      5  sum(decode(t1.code,'TFBG',t.amt,0)) TFBG,
      6  sum(decode(t1.code,'TFMG',t.amt,0)) TFMG
      7  from t1, t
      8  where t.bu=t1.bu
      9  and to_char(t.tdate,'yyyy') = 2005
    10  GROUP BY t1.code, to_char(t.tdate,'MM')
    11  ) tops,
    12  (select rownum mn, to_char(to_date(rownum,'MM'),'MON') mname,
    13  case when rownum between 1 and 3 then rownum + 9
    14  else rownum - 3 end rn
    15  from dict where rownum < 13) pivot_month
    16  where pivot_month.mn = tops.month_no (+)
    17  order by pivot_month.rn
    18  /
    MNA       TFBG       TFMG
    APR      15000          0
    MAY          0      20000
    JUN
    JUL
    AUG
    SEP
    OCT
    NOV
    DEC
    JAN
    FEB
    MAR
    12 rows selected.Rgds.

  • Need SQL Query ---Urgent

    Hi Gurus,
    Select * from xxa_test1
    invoice_type || LOC_CODE|| seq_no
    =========================
    DOMESTIC     A     1
    DOMESTIC     B     2
    DOMESTIC     C     3
    Select * from xxa_test2
    cust_no || cust_name || loc_code
    =======================
    1001 Test B
    1001 Test C
    The Requirement is i want sql query to retrive only one record based on seq no if suppose 2 records retrive in that
    B is having seqno 2 and c having seq no 3
    that sql query should return only one record which is having min seq no. for example in that B, C only B record should return.
    If multiple values returned then the program must check based on the seq no it should take min seq no.
    i have written this query
    Select *
    from xxa_test2 t2
    where t2.loc_code in (select t1.loc_code
    from xxa_test1 t1
    order by Seq_no
    where above query is correct or not , i am getting problem with this query.
    Please let me know its very urgent
    Thanks
    Manju
    Edited by: venu on Jul 26, 2011 12:50 AM

    Something like:
    SELECT cust_no, cust_name, loc_code
    FROM
    (with xxa_test1
    as (SELECT 'DOMESTIC' invoice_type, 'A' loc_code, 1 seq_no FROM dual
    union all
    SELECT 'DOMESTIC', 'B', 2 FROM dual
    union all
    SELECT 'DOMESTIC', 'C', 3 FROM dual),
    xxa_test2
    as (SELECT 1001 cust_no, 'Test' cust_name, 'B' loc_code FROM dual
    union all
    SELECT 1001 , 'Test' , 'C' FROM dual)
    SELECT cust_no, cust_name, t2.loc_code, seq_no, min(seq_no) over() min_seq
    FROM xxa_test2 t2,xxa_test1 t1
    WHERE t2.loc_code = t1.loc_code)
    WHERE seq_no = min_seq
    SQL> /
       CUST_NO CUST L
          1001 Test B

  • Proxy to JDBC scenario need dynamic sql query for sender .

    Hi Experts,
    I am developing proxy to jdbc scenario. in this i need to pass dynamic sql query  whre we are passing classical method like below.
    while we are passing select stmt in constant and mapped with access field  and key field mapped with key field.
    MY requirement is like instead of passing select stmt in constant where i can generate dynamically and passed in one field and mapped with access field.

    Hi Ravinder,
    A simple UDF or use of graphical mapping functions in most cases should provide you everything you need to construct a dynamic SQL statement for your requirement.
    Regards,
    Ryan Crosby

  • Help me write a SQL query; urgent

    Hi, can somebody please help me write a SQL query.
    I have 3 tables each with the same column names (Col1, Col2, Col3). Col1 is PK with Unique Constraint.
    I wanted to add values of Col2 and Col3 (from all 3 tables) and put it in a separate table (i.e aggregated) of all values found in Col1.
    Does anybody help me please ?
    thanks alot.

    Please don't mark your question as urgent. You've been around here long enough that you should know that it will not get your question anwered any faster, and may just irritate people into not answering at all.
    I'm not sure exactly what you want.
    Are you saying you want t1.c2 + t1.c3 + t2.c2 + t2.c3+ t3.c2 + t3.c3 for the rows that have the same c1 in all three tables?
    If so, it would be like this, I think: insert into t4
    select t1.c1
    , t1.c2 + t1.c3 + t2.c2 + t2.c3+ t3.c2 + t3.c3
    from t1, t2, t3
    where t2.c1 = t1.c1
    and t3.c1 = t1.c1If that's not what you want, please clarify.
    And next time maybe you should post your SQL question in a SQL forum.

  • Sql query  - urgent major problem

    If I have the following sql query and I would like to perform a select on this how would I do it.
    select StudentNo, CourseCode, Year, ExamMark from **
    where CourseCode='ELE304' AND Year=1999;
    **select COURSESTUDENT.StudentNo, COURSESTUDENT.CourseCode, COURSESTUDENT.Year, MARKS.ExamMark, MARKS.EntryNo AS RESULT FROM
    COURSESTUDENT LEFT JOIN MARKS ON COURSESTUDENT.StudentNo=MARKS.StudentNo AND COURSESTUDENT.CourseCode='ELE304' AND
    MARKS.CourseCode='ELE304' AND COURSESTUDENT.Year=1999 AND MARKS.Year=1999;

    Ive been trying to get this sql query correct the whole day this is a joke .......
    Someone must know what the prob is...
    thanks
    tzaf

  • Urgent need a SQL Query

    Hi all
    i have a variable that store consequitive ; like 'abc;;;;def;;;gh;;;;lm'.
    i want to replace all the consequitive ; with the single ; .
    eg out put like 'abc;def;gh;lm'
    send the sql or pl/sql ASAP. its very urgent for me.
    thanks in advace

    send the sql or pl/sql ASAP. its very urgent for me.Nobody here cares if something is urgent for you. AT ALL. It is not urgent for us. It is certainly not any more important than other threads on this forum. It IS however completely ignorant for you to assume that your issue is any more important than someone else's issue. Please NEVER use the word urgent in any of your future posts (unless it is relevant to the question)
    On top of that, you have provide a lack of info, such as version, where you are using this value etc.

  • SQL query urgent helps needed!!!

    Hi all,
    I got the following query :-
    SELECT RH.REQUEST_NUMBER,     
         MSIK.CONCATENATED_SEGMENTS,
    MSIK.DESCRIPTION,
         RL.FROM_SUBINVENTORY_CODE,
         RL.UOM_CODE,
         RL.QUANTITY,
    PP.FULL_NAME     ,
         M.TRANSACTION_QUANTITY
    FROM     MTL_TXN_REQUEST_HEADERS RH,
    MTL_TXN_REQUEST_LINES RL,
         MTL_SYSTEM_ITEMS_KFV MSIK,
    FND_USER FU,
    PER_PEOPLE_V7 PP,
              ( SELECT MSIK2.CONCATENATED_SEGMENTS, MOQ.SUBINVENTORY_CODE, SUM(MOQ.TRANSACTION_QUANTITY)
              FROM MTL_ONHAND_QUANTITIES MOQ, MTL_SYSTEM_ITEMS_KFV MSIK2
              WHERE MSIK2.INVENTORY_ITEM_ID = MOQ.INVENTORY_ITEM_ID
              AND MSIK2.ORGANIZATION_ID = 8
              AND MOQ.SUBINVENTORY_CODE LIKE 'ST%'
              GROUP BY MSIK2.CONCATENATED_SEGMENTS, MOQ.SUBINVENTORY_CODE) M
    WHERE     
    RH.HEADER_STATUS IN(3,7,8)
    AND RH.MOVE_ORDER_TYPE IN(1,2)
    and rh.header_id = rl.header_id
    AND MSIK.INVENTORY_ITEM_ID = RL.INVENTORY_ITEM_ID
    AND MSIK.ORGANIZATION_ID = 8
    AND RL.FROM_SUBINVENTORY_CODE LIKE 'ST%'
    AND RH.CREATED_BY = FU.USER_ID
    AND FU.EMPLOYEE_ID = PP.PERSON_ID
    However, when I try to run I got the invalid column for m.transaction_quantity ??? why? does it b'cos of the group sum that I used ?
    My intention of this query to display the sum of total qty from the mtl_onhand_quantities table.
    Please helps.
    Thanks.
    Rgds
    Lim

    sorry if its too late.....
    my guess is alias the SUM(MOQ.TRANSACTION_QUANTITY) in the sub-query table (M) as TRANSACTION_QUANTITY.
    -------- code snippet---------
    FND_USER FU,
    PER_PEOPLE_V7 PP,
    ( SELECT MSIK2.CONCATENATED_SEGMENTS, MOQ.SUBINVENTORY_CODE,
    SUM(MOQ.TRANSACTION_QUANTITY) TRANSACTION_QUANTITY <------------------------------------This is important
    FROM MTL_ONHAND_QUANTITIES MOQ, MTL_SYSTEM_ITEMS_KFV MSIK2
    WHERE MSIK2.INVENTORY_ITEM_ID = MOQ.INVENTORY_ITEM_ID
    AND MSIK2.ORGANIZATION_ID = 8
    AND MOQ.SUBINVENTORY_CODE LIKE 'ST%'
    GROUP BY MSIK2.CONCATENATED_SEGMENTS, MOQ.SUBINVENTORY_CODE) M
    WHERE
    RH.HEADER_STATUS IN(3,7,8)
    AND RH.MOVE_ORDER_TYPE IN(1,2)
    --------------code snippet ends------------------------
    hope this helps,

  • Need help in query urgent...............

    hi......
    i have the table with following structure.
    Table name : master
    id name v_value
    1 ashok 1
    2 balak 2
    3 kathir 4
    4 karan 8
    Input:
    6
    Need output
    id name v_value
    2 bala 2
    3 kathir 4
    Query like
    SELECT * FROM MASTER WHERE V_VALUE IN (<input value>) ;
    if given input value 6 means, how to split the value into 4 and 2....
    if given input value 12 means, how to split the value into 4,8....
    like wise.... for all the combinations..... for the above table values.
    if i give the input value 6 means, i need the query like
    select * from master where v_value in (2,4).
    is split the value is possible by user define function?
    like
    select * from master v_value in (userdefine_function(<input value>));
    if possible means give the function code.
    It is very urgent for my project....
    Thanks,
    S.Ashokkumar
    India.

    Ohh...you made it very simple. how can we accomplish
    the bitwise OR/XOR/...so on.They are all variations on the bitand:
    SQL> var P1 number
    SQL> var P2 number
    SQL> exec :P1 := 4;
    PL/SQL-procedure is geslaagd.
    SQL> exec :P2 := 6;
    PL/SQL-procedure is geslaagd.
    SQL> select :P1 + :P2 - bitand(:P1,:P2) bitor from dual
      2  /
                                     BITOR
                                         6
    SQL> select :P1 + :P2 - 2 * bitand(:P1,:P2) bitxor from dual
      2  /
                                    BITXOR
                                         2
    SQL> exec :P1 := 3;
    PL/SQL-procedure is geslaagd.
    SQL> exec :P2 := 32;
    PL/SQL-procedure is geslaagd.
    SQL> select :P1 + :P2 - bitand(:P1,:P2) bitor from dual
      2  /
                                     BITOR
                                        35
    SQL> select :P1 + :P2 - 2 * bitand(:P1,:P2) bitxor from dual
      2  /
                                    BITXOR
                                        35Regards,
    Rob.

  • Help needed for SQL query

    hello ,
    I am a beginner in terms of writing sql queries. I hope some body can help me out.
    I have two tables
    mysql> desc user_group_t;
    ---------------------------------------------------+
    | Field | Type | Null | Key | Default | Extra |
    ---------------------------------------------------+
    | userAccountId | char(8) | | PRI | | |
    | groupId | char(8) | | PRI | | |
    ---------------------------------------------------+
    2 rows in set (0.00 sec)
    mysql> desc group_t;
    ---------------------------------------------------+
    | Field | Type | Null | Key | Default | Extra |
    ---------------------------------------------------+
    | id | char(8) | | PRI | | |
    | name | char(50) | YES | | NULL | |
    | email | char(100) | YES | | NULL | |
    | description | char(254) | YES | | NULL | |
    | parentId | char(8) | YES | | NULL | |
    | creatorId | char(8) | YES | | NULL | |
    | createDate | char(20) | YES | | NULL | |
    | updateDate | char(20) | YES | | NULL | |
    | updatorId | char(8) | YES | | NULL | |
    ---------------------------------------------------+
    9 rows in set (0.00 sec)
    what I want is list of all groups with id,name and #of members(which is the # of rows in the user_group_t for any given id). Importantly I need the groups with 0 members also to be listed. In short my output should contain exactly the same number of rows as in group_t table with an additional column indicating # of members for that group.
    Any help would be greatly appreciated.
    Thanks in Advance.
    -Vasanth

    Thanks Donald,
    Actually I figured it out, with the following query:
    select id,name,sum(if(groupid is not null,1,0)) as members from group_t left join user_group_t on id=groupid group by id;
    I tried your solution, but mysql says there is an error at '+' . Anyway I modified your solution to the one below and it worked.
    select a.id, a.name, count(b.groupid) from group_t a left join user_group_t b on a.id=b.groupid group by a.id, a.name;
    I tried that before but then I used Count(*) instead of count on groupid. Your solution is elagant and I will go with yours.
    Thanks again.
    Vasanth

  • In line SQL Query - Urgent

    In the problem iam calculating a Stock report.In the SQL suppose the relation F does not return any rows , then (D.ACC_QTY + F.RET_QTY) gives null. How to avoid this problem..
    SELECT A.CLASSIFICATION_CODE, A.ITEM_ABBR, A.ITEM_DESC,
    A.ALT_ITEM_CODE, A.UOM_DESC, A.BASIC_PRICE,
    (A.OPENING_QTY + B.ACC_QTY - C.ISS_QTY)
    OPENING_STOCK, (D.ACC_QTY + F.RET_QTY) ACCEPT_QTY, E.ISS_QTY,
    ((A.OPENING_QTY + B.ACC_QTY - C.ISS_QTY)
    + (D.ACC_QTY + F.RET_QTY) - E.ISS_QTY)
    QTY_IN_HAND
    FROM (SELECT CLASSIFICATION_CODE, ITEM_ABBR, ITEM_DESC,
    ALT_ITEM_CODE, NVL(OPENING_QTY, 0)
    OPENING_QTY, UOM_MASTER.UOM_DESC,
    BASIC_PRICE
    FROM ITEM_MASTER, UOM_MASTER
    WHERE ITEM_MASTER.UOM_CODE = UOM_MASTER.UOM_CODE)
    A,
    (SELECT GRN_DETAIL.ITEM_CODE,
    SUM(NVL(GRN_DETAIL.ACCEPT_QTY, 0))
    ACC_QTY
    FROM GRN_HEADER, GRN_DETAIL
    WHERE GRN_HEADER.GRN_NO = GRN_DETAIL.GRN_NO AND
    GRN_HEADER.GRN_DATE < '01-JAN-2006'
    GROUP BY GRN_DETAIL.ITEM_CODE) B,
    (SELECT MRN_DETAIL.ITEM_CODE,
    SUM(NVL(MRN_DETAIL.ISSUED_QTY, 0))
    ISS_QTY
    FROM MRN_HEADER, MRN_DETAIL
    WHERE MRN_HEADER.MRN_NO = MRN_DETAIL.MRN_NO AND
    MRN_HEADER.MRN_DATE < '01-JAN-2006'
    GROUP BY MRN_DETAIL.ITEM_CODE) C,
    (SELECT GRN_DETAIL.ITEM_CODE,
    SUM(NVL(GRN_DETAIL.ACCEPT_QTY, 0))
    ACC_QTY
    FROM GRN_HEADER, GRN_DETAIL
    WHERE GRN_HEADER.GRN_NO = GRN_DETAIL.GRN_NO AND
    GRN_HEADER.GRN_DATE BETWEEN
    '01-JAN-2006' AND '31-DEC-2006'
    GROUP BY GRN_DETAIL.ITEM_CODE) D,
    (SELECT MRN_DETAIL.ITEM_CODE,
    SUM(NVL(MRN_DETAIL.ISSUED_QTY, 0))
    ISS_QTY
    FROM MRN_HEADER, MRN_DETAIL
    WHERE MRN_HEADER.MRN_NO = MRN_DETAIL.MRN_NO AND
    MRN_HEADER.MRN_DATE BETWEEN
    '01-JAN-2006' AND '31-DEC-2006'
    GROUP BY MRN_DETAIL.ITEM_CODE) E,
         (SELECT B.ITEM_CODE,
    SUM(NVL(B.QUANTITY_ISSUE,0))
    RET_QTY
    FROM MATERIAL_MOVEMENT_HEADER A,MATERIAL_MOVEMENT_DETAIL B
    WHERE A.SLIP_NO = B.SLIP_NO AND
    A.SLIP_DATE BETWEEN
    '01-JAN-2006' AND '31-DEC-2006' AND
              B.TO_JOB_CODE IS NULL
    GROUP BY B.ITEM_CODE) F
    WHERE A.ALT_ITEM_CODE = B.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = C.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = D.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = E.ITEM_CODE (+) AND
         A.ALT_ITEM_CODE = F.ITEM_CODE (+) AND
         A.ALT_ITEM_CODE LIKE 'BOBRNG%017' AND
    A.CLASSIFICATION_CODE = 'BO';

    Sorry members for writing the word 'Urgent'..and really cutting down on your work.
    I am thankful to the person who pointed out my error in the query..it was really simple..should hv solved myself, but even after changing the query with Nvl and changing the business logic to some extent it again fetches no rows..
    The sql given underneath is basically a job-wise stock allocation report..
    SELECT B.JOB_CODE, A.CLASSIFICATION_CODE, A.ITEM_ABBR,
    A.ITEM_DESC, A.ALT_ITEM_CODE, A.UOM_DESC,
    A.BASIC_PRICE, (A.OPENING_QTY + (NVL(B.ACC_QTY, 0)
    + NVL(F.RET_IN, 0)) - (NVL(C.ISS_QTY, 0) + NVL(G.RET_OUT,
    0))) AS OPENING_STOCK, (NVL(D.ACC_QTY, 0)
    + NVL(H.RET_IN, 0)) RECEIVED, (NVL(E.ISS_QTY, 0)
    + NVL(I.RET_OUT, 0)) ISSUED,
    ((A.OPENING_QTY + (NVL(B.ACC_QTY, 0) + NVL(F.RET_IN, 0))
    - (NVL(C.ISS_QTY, 0) + NVL(G.RET_OUT, 0)))
    + (NVL(D.ACC_QTY, 0) + NVL(H.RET_IN, 0)) - (NVL(E.ISS_QTY,
    0) + NVL(I.RET_OUT, 0))) QTY_IN_HAND
    FROM (SELECT CLASSIFICATION_CODE, ITEM_ABBR, ITEM_DESC,
    ALT_ITEM_CODE, UOM_MASTER.UOM_DESC,
    BASIC_PRICE, 0 OPENING_QTY
    FROM ITEM_MASTER, UOM_MASTER
    WHERE ITEM_MASTER.UOM_CODE = UOM_MASTER.UOM_CODE)
    A,
    (SELECT GRN_HEADER.JOB_CODE,
    GRN_DETAIL.ITEM_CODE,
    SUM(NVL(GRN_DETAIL.ACCEPT_QTY, 0))
    ACC_QTY
    FROM GRN_HEADER, GRN_DETAIL
    WHERE GRN_HEADER.GRN_NO = GRN_DETAIL.GRN_NO AND
    GRN_HEADER.GRN_DATE < '01-JAN-2006'
    GROUP BY GRN_HEADER.JOB_CODE,
    GRN_DETAIL.ITEM_CODE) B,
    (SELECT B.TO_JOB_CODE, B.ITEM_CODE,
    SUM(NVL(B.QUANTITY_ISSUE, 0)) RET_IN
    FROM MATERIAL_MOVEMENT_HEADER A,
    MATERIAL_MOVEMENT_DETAIL B
    WHERE A.SLIP_NO = B.SLIP_NO AND
    A.SLIP_DATE < '01-JAN-2006'
    GROUP BY B.TO_JOB_CODE, B.ITEM_CODE) F,
    (SELECT MRN_HEADER.JOB_CODE,
    MRN_DETAIL.ITEM_CODE,
    SUM(NVL(MRN_DETAIL.ISSUED_QTY, 0))
    ISS_QTY
    FROM MRN_HEADER, MRN_DETAIL
    WHERE MRN_HEADER.MRN_NO = MRN_DETAIL.MRN_NO AND
    MRN_HEADER.MRN_DATE < '01-JAN-2006'
    GROUP BY MRN_HEADER.JOB_CODE,
    MRN_DETAIL.ITEM_CODE) C,
    (SELECT B.JOB_CODE, B.ITEM_CODE,
    SUM(NVL(B.QUANTITY_ISSUE, 0)) RET_OUT
    FROM MATERIAL_MOVEMENT_HEADER A,
    MATERIAL_MOVEMENT_DETAIL B
    WHERE A.SLIP_NO = B.SLIP_NO AND
    A.SLIP_DATE < '01-JAN-2006'
    GROUP BY B.JOB_CODE, B.ITEM_CODE) G,
    (SELECT GRN_HEADER.JOB_CODE,
    GRN_DETAIL.ITEM_CODE,
    SUM(NVL(GRN_DETAIL.ACCEPT_QTY, 0))
    ACC_QTY
    FROM GRN_HEADER, GRN_DETAIL
    WHERE GRN_HEADER.GRN_NO = GRN_DETAIL.GRN_NO AND
    GRN_HEADER.GRN_DATE BETWEEN
    '01-JAN-2006' AND '31-DEC-2006'
    GROUP BY GRN_HEADER.JOB_CODE,
    GRN_DETAIL.ITEM_CODE) D,
    (SELECT B.TO_JOB_CODE, B.ITEM_CODE,
    SUM(NVL(B.QUANTITY_ISSUE, 0)) RET_IN
    FROM MATERIAL_MOVEMENT_HEADER A,
    MATERIAL_MOVEMENT_DETAIL B
    WHERE A.SLIP_NO = B.SLIP_NO AND
    A.SLIP_DATE BETWEEN '01-JAN-2006' AND
    '31-DEC-2006'
    GROUP BY B.TO_JOB_CODE, B.ITEM_CODE) H,
    (SELECT MRN_HEADER.JOB_CODE,
    MRN_DETAIL.ITEM_CODE,
    SUM(NVL(MRN_DETAIL.ISSUED_QTY, 0))
    ISS_QTY
    FROM MRN_HEADER, MRN_DETAIL
    WHERE MRN_HEADER.MRN_NO = MRN_DETAIL.MRN_NO AND
    MRN_HEADER.MRN_DATE BETWEEN
    '01-JAN-2006' AND '31-DEC-2006'
    GROUP BY MRN_HEADER.JOB_CODE,
    MRN_DETAIL.ITEM_CODE) E,
    (SELECT B.JOB_CODE, B.ITEM_CODE,
    SUM(NVL(B.QUANTITY_ISSUE, 0)) RET_OUT
    FROM MATERIAL_MOVEMENT_HEADER A,
    MATERIAL_MOVEMENT_DETAIL B
    WHERE A.SLIP_NO = B.SLIP_NO AND
    A.SLIP_DATE BETWEEN '01-JAN-2006' AND
    '31-DEC-2006'
    GROUP BY B.JOB_CODE, B.ITEM_CODE) I
    WHERE A.ALT_ITEM_CODE = B.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = C.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = D.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = E.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = F.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = G.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = H.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = I.ITEM_CODE (+) AND
    B.JOB_CODE = C.JOB_CODE AND
    B.JOB_CODE = D.JOB_CODE AND
    B.JOB_CODE = E.JOB_CODE AND
    B.JOB_CODE = F.TO_JOB_CODE AND
    B.JOB_CODE = G.JOB_CODE AND
    B.JOB_CODE = H.TO_JOB_CODE AND
    B.JOB_CODE = I.JOB_CODE AND
    A.ALT_ITEM_CODE = 'BOSNVL0004-006-002';
    regards,

  • Need help wrt query urgently

    Hi ,
    I have two tables "table1" and "table2".Structure of the both tables are below:
    Table1:
    CustomerId
    CustFname
    CustLname
    Convertion_Date
    Table2:
    CustomerId
    DFname
    DLname
    CustomerId is used for joins .
    Now i need a query based on conversion_date.
    If conversion_date <sysdate
    then
    select CustomerId ,CustFname,CustLname,Convertion_Date from Table1
    else
    select CustomerId,DFname,DLname from Table2
    End .
    I need this functionality in a single query using case statement.
    Please help ..
    Thanks,
    Preethi MR

    Preethi MR wrote:
    Hi ,
    I have two tables "table1" and "table2".Structure of the both tables are below:
    Table1:
    CustomerId
    CustFname
    CustLname
    Convertion_Date
    Table2:
    CustomerId
    DFname
    DLname
    CustomerId is used for joins .
    Now i need a query based on conversion_date.
    If conversion_date <sysdate
    then
    select CustomerId ,CustFname,CustLname,Convertion_Date from Table1
    else
    select CustomerId,DFname,DLname from Table2
    End .
    I need this functionality in a single query using case statement.
    Please help ..
    Thanks,
    Preethi MRIs this urgent homework? Or urgent something else work?
    What exactly makes it urgent?

  • Sql query-urgent

    I would be thankful if anyone could please advise on the sql question as follows:
    id1,dept1,JOHN,12-12-1991
    id2,dept1,JOHN,12-12-1992
    id3,dept1,JOHN,12-12-1993
    id4,dept1,SMITH,11-10-1994
    id5,dept1,SMITH,12-12-1995
    id6,dept1,SMITH,12-12-1996
    id7,dept1,CHRIS,07-07-1997
    id8,dept1,CHRIS,12-12-1998
    I need a query to get the the data when a particular employee was replaced
    as follows:
    name,date_replaced
    JOHN,11-10-1993
    SMITH,07-07-1997
    CHRIS,null
    Any suggestions are most welcome.

      1  select distinct name, last_value(NextHired) over (ORDER BY dept,name)
      2  from
      3  (with emp as
      4    (select 'id1' id,
      5            'dept1' dept,
      6            'JOHN' name,
      7            to_date('12-12-1991' ,'DD-MM-YYYY') hiredate from dual
      8     union
      9     select 'id2','dept1','JOHN',to_date('12-12-1992' ,'DD-MM-YYYY') from dual
    10     union
    11     select 'id3','dept1','JOHN',to_date('12-12-1993' ,'DD-MM-YYYY') from dual
    12     union
    13     select 'id4','dept1','SMITH',to_date('11-10-1994','DD-MM-YYYY') from dual
    14     union
    15     select 'id5','dept1','SMITH',to_date('12-12-1995','DD-MM-YYYY') from dual
    16     union
    17     select 'id6','dept1','SMITH',to_date('12-12-1996','DD-MM-YYYY') from dual
    18     union
    19     select 'id7','dept1','CHRIS',to_date('07-07-1997','DD-MM-YYYY') from dual
    20     union
    21     select 'id8','dept1','CHRIS',to_date('12-12-1998','DD-MM-YYYY') from dual)
    22  select id,name, dept,lead (hiredate,1) OVER (ORDER BY hiredate) AS NextHired
    23  from   emp
    24  order by id, dept)
    25* order by last_value(NextHired) over (ORDER BY dept,name)
    SQL> /
    JOHN  11/10/94
    SMITH 07/07/97
    CHRIS
    SQL> Nicolas.
    Message was edited by:
    N. Gasparotto
    Hmm, rajeevm, you wrote JOHN,11-10-1993, but it seems it's a mistake... isn't it ?

  • Need the sql query for IN clause.

    Hi All,
    i have item data like --
    IBM 200 and IBM 500
    have present code like this ----select * from emp where in (IBM 200 and IBM 500);
    so i need change or repalce like ('IBM 200','IBM 500')
    Any body please help me out this..
    Need to get out put 'IBM 200','IBM 500' from data IBM 200 and IBM 500 ...
    Edited by: anbarasan on Oct 17, 2011 10:30 PM

    Please consider the following when you post a question. This would help us help you better
    1. New features keep coming in every oracle version so please provide Your Oracle DB Version to get the best possible answer.
    You can use the following query and do a copy past of the output.
    select * from v$version 2. This forum has a very good Search Feature. Please use that before posting your question. Because for most of the questions
    that are asked the answer is already there.
    3. We dont know your DB structure or How your Data is. So you need to let us know. The best way would be to give some sample data like this.
    I have the following table called sales
    with sales
    as
          select 1 sales_id, 1 prod_id, 1001 inv_num, 120 qty from dual
          union all
          select 2 sales_id, 1 prod_id, 1002 inv_num, 25 qty from dual
    select *
      from sales 4. Rather than telling what you want in words its more easier when you give your expected output.
    For example in the above sales table, I want to know the total quantity and number of invoice for each product.
    The output should look like this
    Prod_id   sum_qty   count_inv
    1         145       2 5. When ever you get an error message post the entire error message. With the Error Number, The message and the Line number.
    6. Next thing is a very important thing to remember. Please post only well formatted code. Unformatted code is very hard to read.
    Your code format gets lost when you post it in the Oracle Forum. So in order to preserve it you need to
    use the {noformat}{noformat} tags.
    The usage of the tag is like this.
    <place your code here>\
    7. If you are posting a *Performance Related Question*. Please read
       {thread:id=501834} and {thread:id=863295}.
       Following those guide will be very helpful.
    8. Please keep in mind that this is a public forum. Here No question is URGENT.
       So use of words like *URGENT* or *ASAP* (As Soon As Possible) are considered to be rude.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for

  • Hierarchy blank duplication in report

    Dear All,               I have made an infoset which contains 2 infoproviders. 0Employee, 0profit_ctr. Employee no. and profit_ctr is joined through foriegn key emp.profitctr and profitctr. The problem here is profit ctr  contains time dependent hier

  • How to add records in Infotype 1028

    Hi Experts, I'm trying with Functions HR_INFOTYPE_OPERATION and RH_PNNNN_MAINTAIN, I've no results.

  • Cursor positioning with adobe acrobat

    Using Macbook Air with snow leopard and adobe acrobat 10.1.1: cursor remains several lines high and to the left of actual insertion point making it very difficult to select menu icons or text insertion points. Any suggestions?

  • Open Quotations

    Hi,       Is there any option other   than  VA25 to check the list of open quotations .I want the list of customers with there open quantites of quotation.

  • Adding thumbnails to xml playlist

    I am new to flash and I have a questions that I think should be pretty simple but I can't seem to figure it out. I'm creating a flash page with an xml video player, and my actionscript works fine, but I would like to add thumbnails to the playlist. C