QUERY CLARIFICATION RQD :  gurus, experts pls help

Hai,
I am facing problem in performance of the query. sample scenario i have created here pls help me to solve
**VEH_MAIN* TABLE (MASTER TABLE)*
CREATE TABLE VEH_MAIN
   (     VIP_MOT_IND VARCHAR2(10 BYTE),
     VIP_IND NUMBER(10,0)
Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('MOT01',1);
Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('MOT02',5);
Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('M0T03',1);
Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('MOT01',2);
Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('MOT02',6);
Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('MOT01',3);
Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('MOT01',4);
**VEH_ENGINE_SUB* (table for engine subclass)*
  CREATE TABLE VEH_ENG_SUB
   (     ENG_SUBCLASS VARCHAR2(50 BYTE),
     ENG_MOT_IND VARCHAR2(10 BYTE)
Insert into VEH_ENG_SUB (ENG_SUBCLASS,ENG_MOT_IND) values ('ENGSUB001','MOT01');
Insert into VEH_ENG_SUB (ENG_SUBCLASS,ENG_MOT_IND) values ('ENGSUB001','MOT02');
*VEH_ENG_IND( Detail table for engine subclass)*
  CREATE TABLE VEH_ENG_IND
   (     "ENG_SUBCLASS" VARCHAR2(50 BYTE),
     "ENG_IND" VARCHAR2(10 BYTE)
Insert into VEH_ENG_IND (ENG_SUBCLASS,ENG_IND) values ('ENGSUB001','1');
Insert into VEH_ENG_IND (ENG_SUBCLASS,ENG_IND) values ('ENGSUB001','2');
*VEH_AXIS( Master table for Engine Axis)*
CREATE TABLE VEH_AXIS
   (     ENG_AXIS VARCHAR2(50 BYTE),
     AXIS_MOT_IND VARCHAR2(10 BYTE)
Insert into VEH_AXIS (ENG_AXIS,AXIS_MOT_IND) values ('ENGAXIS001','MOT01');
Insert into VEH_AXIS (ENG_AXIS,AXIS_MOT_IND) values ('ENGAXIS002','MOT02');
*VEH_AXIS_IND( Details table for engine axis)*
CREATE TABLE VEH_AXIS_IND
   (     ENG_AXIS VARCHAR2(50 BYTE),
     ENG_IND VARCHAR2(10 BYTE)
Insert into VEH_AXIS_IND (ENG_AXIS,ENG_IND) values ('ENGAXIS001','1');
Insert into VEH_AXIS_IND (ENG_AXIS,ENG_IND) values ('ENGAXIS001','2');
Insert into VEH_AXIS_IND (ENG_AXIS,ENG_IND) values ('ENGAXIS001','3');
Insert into VEH_AXIS_IND (ENG_AXIS,ENG_IND) values ('ENGAXIS001','4');
Insert into VEH_AXIS_IND (ENG_AXIS,ENG_IND) values ('ENGAXIS002','5');
Insert into VEH_AXIS_IND (ENG_AXIS,ENG_IND) values ('ENGAXIS002','6');
Condition 1
if i select only ENGINE_SUBCLASS='ENGSUB001' then
SELECT  vip_mot_ind,vip_ind
FROM veh_main V,
veh_eng_sub vsub,
veh_eng_ind  vind
WHERE (v.vip_mot_ind= vsub.eng_mot_ind
and   v.vip_ind=vind.eng_ind
and    vsub.eng_subclass= vind.eng_subclass
AND vsub.eng_subclass='ENGSUB001' )output is
MOT01     1
MOT01     2
Condition 2:if i select only the Engine Axis='ENGAXIS002' then the
SELECT  vip_mot_ind,vip_ind
FROM veh_main V,
veh_axis  vaxis,
veh_axis_ind vaind
WHERE  v.vip_mot_ind= vaxis.axis_mot_ind
and   v.vip_ind= vaind.eng_ind
and   vaind.eng_axis= vaxis.eng_axis
and   vaxis.eng_axis='ENGAXIS002';MOT02     5
MOT02     6
Condition 3:
BOTH ENGINE AXIS AND ENGINE SUBCLASS
SELECT  vip_mot_ind,vip_ind
FROM veh_main V,
veh_eng_sub vsub,
veh_eng_ind  vind,
veh_axis  vaxis,
veh_axis_ind vaind
WHERE (v.vip_mot_ind= vsub.eng_mot_ind
and   v.vip_ind=vind.eng_ind
and    vsub.eng_subclass= vind.eng_subclass
AND vsub.eng_subclass='ENGSUB001' )
AND  ( v.vip_mot_ind= vaxis.axis_mot_ind
and   v.vip_ind= vaind.eng_ind
and   vaind.eng_axis= vaxis.eng_axis
and   vaxis.eng_axis='ENGAXIS002');Null values returned. this is correct.
But the query PERFORMANCE fails in OR CONDITON as below
Condition 4;
SELECT  vip_mot_ind,vip_ind
FROM veh_main V,
veh_eng_sub vsub,
veh_eng_ind  vind,
veh_axis  vaxis,
veh_axis_ind vaind
WHERE (v.vip_mot_ind= vsub.eng_mot_ind
and   v.vip_ind=vind.eng_ind
and    vsub.eng_subclass= vind.eng_subclass
AND vsub.eng_subclass='ENGSUB001' )
OR  ( v.vip_mot_ind= vaxis.axis_mot_ind
and   v.vip_ind= vaind.eng_ind
and   vaind.eng_axis= vaxis.eng_axis
and   vaxis.eng_axis='ENGAXIS002');output
MOT02     5
MOT02     5
MOT02     5
MOT02     5
MOT02     6
MOT02     6
MOT02     6
MOT02     6
MOT01     1
MOT01     1
MOT01     1
MOT01     1
MOT01     1
MOT01     1
MOT01     1
MOT01     1
MOT01     1
MOT01     1
MOT01     1
MOT01     1
MOT01     2
MOT01     2
MOT01     2
MOT01     2
MOT01     2
MOT01     2
MOT01     2
MOT01     2
MOT01     2
MOT01     2
MOT01     2
MOT01     2
This is sample example. when i implement in huge table with partition this scennario takes much time even 2 hours to run.
i want the output must be as below if i use OR condition like condition 4
MOT01     1
MOT01     2
MOT02     5
MOT02     6
Gurus and experts pls help me to solve this problem. Dont give any suggestion like
SELECT  vip_mot_ind,vip_ind
FROM veh_main V,
veh_axis  vaxis,
veh_axis_ind vaind
WHERE  v.vip_mot_ind= vaxis.axis_mot_ind
and   v.vip_ind= vaind.eng_ind
and   vaind.eng_axis= vaxis.eng_axis
and   vaxis.eng_axis='ENGAXIS002'
union
SELECT  vip_mot_ind,vip_ind
FROM veh_main V,
veh_eng_sub vsub,
veh_eng_ind  vind
WHERE (v.vip_mot_ind= vsub.eng_mot_ind
and   v.vip_ind=vind.eng_ind
and    vsub.eng_subclass= vind.eng_subclass
AND vsub.eng_subclass='ENGSUB001' )
}this will give correct result...
MOT01     1
MOT01     2
MOT02     5
MOT02     6
but the problem is we cannot implement this in query. because query get framed at runtime there will be so many implement has to be done. other than UNION pls give me more suggesion
waiting..
S
Edited by: A Beginner on Sep 11, 2010 12:51 AM

create a view v1 with all the joins
select * from v1 where eng_subclass='ENGSUB001'
union
select * from v1 where eng_axis='ENGAXIS002'
If you really do not like the direct access with union, try this
select * from v1
where vsub_PK in (select vsub_PK from v1 where eng_subclass='ENGSUB001' )
OR vsub_PK in (select vsub_PK from v1 where eng_axis='ENGAXIS002')
--vsub_PK is the primary key of table vsub                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Any java experts pls help me in converting attribute to XML formats

    Pls help me oh my god i am a newbie here and i am given this project.
    I had just written a XML doc. which looks like this
    <ConsumerTransfer>
    <TransactionId>
    123:123
    </TransactionId>
    <Billingoption>
    cash
    </Billingoption>
    </ConsumerTransfer>
    I need to make this to attributes like
    private String TransactionId()
    private String BillingOption()
    and so on.....
    I need to convert this attributes to XML format
    can any show me an example or the source codes for this
    Really, I appreciate it.
    JimmyKnot

    For such node level operations I think that DOM would be a good idea. So here you go. Look for some nice tutorial for DOM and you got it.
    salut

  • Hi experts pls help me with this materialized view refresh time!!!

    Hi Expeerts ,
    Please clarify my doubt about this materialized view code
    [\n]
    CREATE MATERIALIZED VIEW SCHEMANAME.products_mv
    REFRESH WITH ROWID
    AS SELECT * from VIEW_TABLE@DATAOPPB;
    [n]
    Here i am creating a materialized view named products_mv of the view_table present in the remote server.Can anyone tell me when will my table product_mv will get refreshed if i follow this code.As what i read from the books is that the refresh period is implicit and is carried out by the database implicitly.so can u tell me suppose i insert 2 new records into my view_table when will this record get updated into my product_mv table.
    I cant use primary key approach so this is the approach i am following .Kindly help me in understanding when will refresh of records occur in the materialized view product_mv...Pls help
    regards
    debashis

    Hi Justin ,
    Yes, my database can reasonably schedule other jobs too .Its not an issue.
    Actually what i meant "fine in all aspects" is that will the matrerialized view will get refreshed w.r.t the documetum_v table present in my remote server.This is all i need to refresh my materialized view .
    I queries the DBA_JOBS table .I could see the following result i have pasted below:-
    [\n]
    NLS_ENV
    MISC_ENV INSTANCE
    dbms_refresh.refresh('"WORKFLOW"."PRODUCTS_MV2"');
    JOB LOG_USER PRIV_USER
    SCHEMA_USER LAST_DATE LAST_SEC THIS_DATE THIS_SEC NEXT_DATE
    NEXT_SEC TOTAL_TIME B
    INTERVAL
    FAILURES
    WHAT
    [n]
    here WORKFLOW"."PRODUCTS_MV2 is the materialized view i have created.So can u tell me that whether we can predict our refresh part is functioning fine from this data.If so how?
    Actually i am asking u in details as i dont have much exposure to materialized view .I am using it for the very first time.
    Regds
    debashis

  • URGENT, EXPERTS PLS HELP!!

    I would like to know answer to following question:
    "Is java.lang.Object" overused??? Pls reply immediately coz I doing my final year project at ivy league university and I need to hand in my assignment in next 2 hours!

    "Is java.lang.Object" overused??? Pls reply
    immediately coz I doing my final year project at ivy
    league university and I need to hand in my assignment
    in next 2 hours!I love the story this implies. This issue is critical to a final year project? A final year project? Due in September?
    How could it be relevant? I mean, if the final year project is an argument about the overuse of a particular idiom, then presumably the project is in the OP's area of expertise. So why is he asking about it here, now?
    And if it's not his area of expertise... then he'd be expected to do some research, such as interviews. He'd be expected to do some research somewhat earlier than two hours before the project is due.
    And of course the coup de grace, informing us that it's in an ivy league school. Those of us who weren't so fortunate to attend one, are of course obligated to help out those who do.
    He must go to Yale.
    Otherwise...a marvelous troll, sir!

  • Query to  get  Week number  Pls help

    I need to get week number of the current year in the format 2008-W47 ( this is for sysdate
    when i try
    select to_CHAR(sysdate,'YYYY'||'-IW')
    FROM DUAL
    i get 2008-47
    but in the format 2008-W47
    Help
    s

    SQL> select to_CHAR(sysdate,'YYYY')||'-W'||to_char(sysdate,'IW') from dual
      2  /
    TO_CHAR(
    2008-W47

  • OCA certification (Senior, expert pls help!!)

    Hi all, i am currently a java programmer and is keen to get OCA certify.
    May i know what is the difference between 10g n 11g?
    Also, y do i need to take 2 exams for 11g but onli 1 exam for 10g???
    Lastly, is it possible to SELF STUDY for OCA as i do not have any oracle experience. Only have MS sql experience.
    Thank You

    hi thanks for your valued info.
    But why is there only 1 exam needed for 10g and 2 for 11g?Oracle removed the 'SQL for beginners' exam for the 10g series. That [to me at least] proved to be a mistake as too many people were attempting to get certified without even beginner knowledge of the very language that runs the Oracle database platform. They restored that exam. Now there is verification that the OCA candidate at least can spell SQL, SELECT, UPDATE and so on, and might even be able to use the tools provided.
    >
    Based on your view, do u think i should start all
    over from 9i then slowly upgrade or, take 11g directly?
    Pls advise:)I think you should think about your future. Make a decision for yourself based on that. Does you future include Oracle9i DB? Is it important for you to verify that you understand Oracle9i DB?
    Many people mistakenly think the purpose of the exam is to get a certificate. I disagree ... I think the purpose of certification is to verify - to yourself and to others - that you are aware of, and potentially understand, the material. (If you use brain dumps, or gunners, or other ways of cheating, you are not verifying that awareness or understanding and will eventually be caught - by your colleagues, your boss, or perhaps by yourself when you look at your reflection in the morning mirror.)
    If you do not want to verify your knowledge about 9i, don't bother.

  • 5200: Error executing query: Invalid Item ID. Pls help

    Hi
    i get this error above when i try to run a report from the workspace and it's specially for some reports.
    I use HFM 9.2, the database connection is configured correctly, and the user with the problem
    above (comes from msad) has all the rights, permissions and he can run others reports without any problem.
    Any idea to fix this issue?
    thanks for your help

    We had several users experiencing this on various reports. This was due to an invalid default Point of View for the user that was incompatible with the particular report. We changed their preferences to prompt for POV and it solved the issue.
    This can be changed in Workspace (we are on 9.3.1, so it may be a little different) under File | Preferences. Choose Financial Reporting and set the User Point of View Preview value to On. This will prompt the user to change their POV every time he or she opens a report. They can select the correct POV and the report runs correctly.
    Let me know if this works. If not, you can delete the POV from the server and it will reset when the user logs back in.

  • Tree creation algorithm needed. Experts pls help

    hi,
    I'm writing a program that read data from database to create a Tree.
    The database table:
    DATA          PREDATA          POSTDATA
    1 4 5
    2 6 7
    3 1 2
    4 8 9
    If the DATA has a PREDATA, it will be inserted into the left node otherwise null and POSTDATA will be inserted into right node. For example if I pass in 3 the Tree should look like the following:
    3
    1 2
    4 5 6 7
    8 9 null null null
    Thanks

    This is a fairly straighforward problem but I see two possible problems.
    1) There could be more than one root. Any row with identifier that is never used as pre or post is a root.
    2) If a row identifier is used more than once as pre or post then one no longer has a simple binary tree.
    Dealing with 1) is easy - just have a set of roots. Dealing with 2) is not so easy.
    My solution follows. It deals with 1 but not 2.
    import java.util.*;
    public class Test20040622
        static String[][] testData =
            {"1","4","5"},
            {"2","6","7"},
            {"3","1","2"},
            {"4","8","9"},
        static class TreeElement
            TreeElement(String value, Object pre, Object post)
                this.value = value;
                this.pre = pre;
                this.post = post;
            public String toString()
                return value;
            String value;
            Object pre;
            Object post;
        private Set treeRoots;
        public Test20040622()
            HashMap map = new HashMap();
            // Build a map pointing from id to TreeElement
            for (int rowIndex = 0; rowIndex < testData.length; rowIndex++)
                String[] row = testData[rowIndex];
                map.put(row[0], new TreeElement(row[0], row[1], row[2]));
            // The set of keys to the TreeElements
            treeRoots = new HashSet(map.keySet());
            // Go through each of the elements replacing the
            // pre and post String with the corresponding TreeElement
            for (Iterator it = map.values().iterator(); it.hasNext();)
                TreeElement treeElement = (TreeElement)it.next();
                if (treeElement.pre instanceof String)
                    treeRoots.remove(treeElement.pre);
                    Object pre = map.get(treeElement.pre);
                    if (pre != null)
                        treeElement.pre = pre;
                if (treeElement.post instanceof String)
                    treeRoots.remove(treeElement.post);
                    Object post = map.get(treeElement.post);
                    if (post != null)
                        treeElement.post = post;
            // Convert the tree root Strings to TreeElements
            HashSet roots = new HashSet();
            for (Iterator it = treeRoots.iterator(); it.hasNext();)
                roots.add(map.get(it.next()));
            treeRoots = roots;
        public void print()
            for (Iterator it = treeRoots.iterator(); it.hasNext();)
                printOne(it.next(), 0);
        private void printOne(Object leaf, int level)
            if (leaf instanceof TreeElement)
                printOne( ((TreeElement)leaf).pre, level+1);
            for (int i = 0; i < level; i++)
                System.out.print("   ");
            System.out.println(leaf);
            if (leaf instanceof TreeElement)
                printOne(((TreeElement)leaf).post, level+1);
        public static void main(String[] args)
            new Test20040622().print();
    }

  • Expert pls help: Sun IDM with ldap active sync

    Hi all,
    Currently i am configuring Sun IDM 6.0 SP1 to active sync with Sun directory server. I have enabled Retro Change Log but yet i cant find my changeNumber in directory server. Could anyone show me a way (search?) to get what changeNumber directory server currently running?

    Check the account used by IDM to access DS can search cn=changelog branch. If he is not Directory Manager, you probably need to set an ACI on that branch.
    HTH

  • Ordering according comparing - SQL Experts pls help

    Hi All,
    I want to measure the nearest points according to percentage between these points and order it.
    by another way, i want to show the relation between points according to percentage value.
    drop table temp_value;
    create table temp_value(id number(10),location varchar2(20), percentage number(9));
    insert into temp_value values  (1,'LOC 1,2',30);
    insert into  temp_value values (2,'LOC 1,3',0);
    insert into  temp_value values (3,'LOC 1,4',0);
    insert into  temp_value values (4,'LOC 1,5',0);
    insert into  temp_value values (5,'LOC 1,6',50);
    insert into  temp_value values (6,'LOC 2,3',0);
    insert into  temp_value  values(7,'LOC 2,4',0);
    insert into  temp_value values (9,'LOC 2,5',0);
    insert into  temp_value values (10,'LOC 2,6',10);
    insert into  temp_value values (11,'LOC 3,4',90);
    insert into  temp_value values (12,'LOC 3,5',80);
    insert into  temp_value values (13,'LOC 4,5',0);
    insert into  temp_value values (14,'LOC 4,6',0);
    insert into  temp_value values (15,'LOC 5,6',0); i want the output like this, the ordering of the point like this
    4
    3
    5
    6
    1
    2 or like this
      6
    1
    2
    4
    3
    5 if you ask me why this ordering i will say that
    4    [90 percent between point 3,4 that mean can be 3,4 or 4,3]
    3
    5    [80 percent between 3,5 that mean can be 5 after 3,4]
    6    [50 percent between 1,6 that mean can be 1,6 or 6,1 ]
    1
    2    [ 30 percent between 1,2 that mean can be 1,2 or 2,1] regards
    Edited by: Ayham on Oct 6, 2012 10:18 AM
    Edited by: Ayham on Oct 6, 2012 10:43 AM
    Edited by: Ayham on Oct 6, 2012 8:04 PM

    really i am happy to see you reply but the results is not correct
    SQL> select A1.loc as Location, A1.rn as percentage, a2.rw as group_number from
    asd a1,
      2                     (Select rn, row_number() over(order by rn desc) rw
      3                     from asd
      4                     group by rn) a2
      5  where a1.rn = a2.rn;
    LOCATION             PERCENTAGE GROUP_NUMBER
    4                            90            1
    3                            90            1
    5                            80            2
    3                            80            2
    6                            50            3
    1                            50            3
    2                            30            4
    1                            30            4
    6                            10            5
    2                            10            5
    6                             0            6
    LOCATION             PERCENTAGE GROUP_NUMBER
    6                             0            6
    5                             0            6
    5                             0            6
    5                             0            6
    5                             0            6
    4                             0            6
    4                             0            6
    4                             0            6
    4                             0            6
    3                             0            6
    3                             0            6
    LOCATION             PERCENTAGE GROUP_NUMBER
    2                             0            6
    2                             0            6
    2                             0            6
    1                             0            6
    1                             0            6
    1                             0            6
    28 rows selected.
    SQL>it should be like this
    LOC          Group
    3                    1
    4                    1
    5                    1
    1                    2
    6                    2
    2                    2Edited by: Ayham on Oct 6, 2012 1:11 AM
    Edited by: Ayham on Oct 6, 2012 1:11 AM

  • Query to Translate and Replace: Pls Help

    I have a table which contains days of the week (in numbers) in a comma separated format. I need to replace the numbers with "Abbreviated Days of the Week"
    For example, I ahve some sample rows as
    1
    1,2
    1,5,6
    3,5
    This must be printed out as
    MON
    MON,TUE
    MON,FRI,SAT
    WED,FRI
    In the above case, 0 is replaced by SUN, 1 by MON and so on...

    why not a simple (although scarry looking) nested replace?
    replace(replace(replace(replace(replace(replace(replace(the_column,'0','SUN'),'1','MON'),'2','TUE'),'3','WED'),'4','THU'),'5','FRI'),'6','SAT')Regards
    Etbin
    Message was edited by:
    Etbin

  • Consecutive Absent Days  Query.. Pls Help Gurus

    I have a table which stores attendance information
    For eg:
    Emp_No Date
    100 01-APR-2010
    102 05-APR-2010
    100 02-APR-2010
    I need a query with parameter From Date and To date..
    My Query Output should be like this .. considering that employee 100 is absent for 8 consecutive days and employee number 102 is absent for 2 consecutive days..
    It should return number of consecutive days he is absent.
    Empno Consecutive Days
    100 8 Days
    102 2 Days
    Pls Help Gurus.
    Edited by: suzvino on Jun 21, 2010 12:14 AM

    TUBBY_TUBBZ?with data as
      2  (
      3     select 100 as emp_no, to_date('01-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      4     select 102 as emp_no, to_date('05-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      5     select 100 as emp_no, to_date('02-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      6     select 100 as emp_no, to_date('01-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      7     select 100 as emp_no, to_date('03-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      8     select 100 as emp_no, to_date('04-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      9     select 100 as emp_no, to_date('05-APR-2010','dd-mon-yyyy') as absent_date from dual union all
    10     select 100 as emp_no, to_date('06-APR-2010','dd-mon-yyyy') as absent_date from dual union all
    11     select 100 as emp_no, to_date('07-APR-2010','dd-mon-yyyy') as absent_date from dual union all
    12     select 100 as emp_no, to_date('08-APR-2010','dd-mon-yyyy') as absent_date from dual union all
    13     select 100 as emp_no, to_date('09-APR-2010','dd-mon-yyyy') as absent_date from dual
    14  )
    15  select
    16     emp_no, max(level)
    17  from data
    18  connect by prior emp_no = emp_no and prior absent_date = absent_date - 1
    19  group by emp_no
    20  having max(level) >= 8;
                EMP_NO         MAX(LEVEL)
                   100                  9
    1 row selected.
    Elapsed: 00:00:00.01
    TUBBY_TUBBZ?Think i misread the post, so the query should be
    TUBBY_TUBBZ?with data as
      2  (
      3     select 100 as emp_no, to_date('01-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      4     select 102 as emp_no, to_date('05-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      5     select 100 as emp_no, to_date('02-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      6     select 100 as emp_no, to_date('01-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      7     select 100 as emp_no, to_date('03-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      8     select 100 as emp_no, to_date('04-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      9     select 100 as emp_no, to_date('05-APR-2010','dd-mon-yyyy') as absent_date from dual union all
    10     select 100 as emp_no, to_date('06-APR-2010','dd-mon-yyyy') as absent_date from dual union all
    11     select 100 as emp_no, to_date('07-APR-2010','dd-mon-yyyy') as absent_date from dual union all
    12     select 100 as emp_no, to_date('08-APR-2010','dd-mon-yyyy') as absent_date from dual union all
    13     select 100 as emp_no, to_date('09-APR-2010','dd-mon-yyyy') as absent_date from dual
    14  )
    15  select
    16     emp_no, max(level)
    17  from data
    18  connect by prior emp_no = emp_no and prior absent_date = absent_date - 1
    19  group by emp_no;
                EMP_NO         MAX(LEVEL)
                   100                  9
                   102                  1
    2 rows selected.
    Elapsed: 00:00:00.01Edited by: Tubby on May 30, 2010 11:00 PM
    Added second query since i misread the post originally.

  • SQL query...pls help ASAP

    Actor (Aname: varchar(40), Ano: varchar(6)) Ano is pk
    Movie (Mname: varchar(40),mno: varchar(8)) Mno is pk
    PlayIn (Ano, Mno, Pay: Integer) Ano and Mno are fk referencing Acotr and Movie respectively.
    Actor(Aname, Ano)
    A Bingo, A1
    B Castro, A2
    C Katie, A3
    S Hommy, A4
    J Tammy, A5
    K loren, A6
    Movie(Mname, Mno)
    Gladiator, M1
    Cast, M2
    Dog, M3
    Jilters, M4
    PlayIn(Ano,Mno,Pay)
    A1 M1 800
    A1 M2 1500
    A2 M2 78
    A2 M3 1750
    A2 M4 2301
    A3 M2 904
    A3 M3 629
    A4 M2 565
    A4 M3 5695
    A4 M4 1255
    A5 M1 989
    A5 M4 238
    A6 M2 137
    A6 M3 236
    A6 M4 545
    QUESTION: write SQL query to find the names of actors who earned less than 'B Castro' in each movie that 'B Castro' played in.

    thanks so so much.....
    another question:
    for each movie, list the movie number, the average
    pay and the total number of actors in the movie.....Rather than just asking homework questions and expecting everyone else to do your work for you, why don't you at least have a go at it yourself and post the query that you've tried, then we'll tell you where you are going wrong. You won't learn anything if we just write it for you.
    Also, your use of "pls help ASAP" in the subject title is not polite.
    This forum is manned by volunteers who have their own jobs and offer their help free of charge.
    Everyone who posts an issue on here would love to have it answered as soon as possible, but nobody has the right to assume that their issue is any more important, urgent or requires a quicker answer than anybody elses.
    If you need urgent help then you should pay someone to do the work for you.

  • Query on Time Scheduling ............................Urgent pls help

    Dear Friends
      Here is my query on Background processing,
      I want to run a program in background which ll save the details in AL11.
      I want to schedule this object between 12 AM night to 2 AM night as per the indian time standard.
      The data should be save the data in al11 as the following format=>
      1-It ll show the PO details that has been created between 12-1 and 1-2,it should not show 12-1 data in 1-2 means between 12 to 2 i ll store the data in AL11 that has been created between these one hour time if it would more than one hour than last one hour data it wont show in al11.
      Now the Pos that has been created between 2 am to next day night should be display when the user ll run the report at next day 12 o'clock.
    Can you give me the following idea,
    1-Which table stores the background scheduling time,if NAST than what is the field name.
    If anyone solve this kind of prob,pls help me on this.
    Thanks a lot
    mrutyun^

    Hi,
    Try table<b> TBTCS</b> which stores Background Processing: Time Schedule.
    Regards,
    Amit

  • SQL experts please help for a query

    I have following table1.
    What query can give the result as given below, SQL experts please help on this.
    TABLE1
    Event DATETIME
    in 2/JAN/2010
    out 2/JAN/2010
    in 13/JAN/2010
    out 13/JAN/2010
    in 5/JAN/2010
    out 5/JAN/2010
    RESULT REQUIRED FROM THE SQL QUERY
    COL1_IN COL2_OUT
    2/JAN/2010 2/JAN/2010
    13/JAN/2010 13/JAN/2010
    5/JAN/2010 5/JAN/2010

    I tried to help, but this puzzles me.
    Why is this not returning pre-selected set of rows, why it's doing some merge join cartezian ?
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL> select * from table1;
    EVENT      DATETIME
    in         2/JAN/2010
    out        2/JAN/2010
    in         13/JAN/2010
    out        13/JAN/2010
    in         5/JAN/2010
    out        5/JAN/2010
    6 rows selected.
    SQL> explain plan for
      2  with a as
    (select datetime from table1 where event='in'),
    b as
    (select datetime from table1 where event='out')
    select  a.datetime COL1_IN ,b.datetime COL2_OUT from a,b ;
    Explained.
    SQL> set wrap off
    SQL> set linesize 200
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 185132177
    | Id  | Operation            | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |        |     9 |   288 |     8   (0)| 00:00:01 |
    |   1 |  MERGE JOIN CARTESIAN|        |     9 |   288 |     8   (0)| 00:00:01 |
    |*  2 |   TABLE ACCESS FULL  | TABLE1 |     3 |    48 |     3   (0)| 00:00:01 |
    |   3 |   BUFFER SORT        |        |     3 |    48 |     5   (0)| 00:00:01 |
    |*  4 |    TABLE ACCESS FULL | TABLE1 |     3 |    48 |     2   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       2 - filter("EVENT"='in')
       4 - filter("EVENT"='out')
    Note
       - dynamic sampling used for this statement
    21 rows selected.
    SQL> with a as
    (select datetime from table1 where event='in'),
    b as
    (select datetime from table1 where event='out')
    select  a.datetime COL1_IN ,b.datetime COL2_OUT from a,b ;
    COL1_IN         COL2_OUT
    2/JAN/2010      2/JAN/2010
    2/JAN/2010      13/JAN/2010
    2/JAN/2010      5/JAN/2010
    13/JAN/2010     2/JAN/2010
    13/JAN/2010     13/JAN/2010
    13/JAN/2010     5/JAN/2010
    5/JAN/2010      2/JAN/2010
    5/JAN/2010      13/JAN/2010
    5/JAN/2010      5/JAN/2010
    9 rows selected.
    SQL>

Maybe you are looking for