SQL query for date & time interval

Hello everyone,
there is my problem
I have to make a search for events that are taking place during inserted date & time .
There's the table structure:
event
datefrom
dateto
timefrom
timeto
The problem is, when I try:
select * from xyz where datefrom <= inserted_date and dateto >= inserted_date and timefrom <= inserted_time and timeto >= inserted time;
then I don't get back all records.
eg: user inserts date = 10.10.2010 and time 10:00 and in the table is event [abc 11:00 9.10.2010 -> 09:00 11.10.2010] stored following way:
event         abdc
datefrom   09.10.2010
dateto        11.10.2010
timefrom    11:00
timeto         09:00
=> this event won't be found, because the sql logic compares only single parameters and not their context.
Do you have any idea, how to solve this issue?
Thank you.
Lukas

Hello Hubert,
thank you very much for your proposal, but your code makes the same select as mine (but in a more user friendly look :).
Table:
datefrom 09.10.2010
dateto 11.10.2010
timefrom 11:00
timeto 09:00
Event date = 10.10.2010 and time 10:00.
Your query:
select * from xyz where 10.10.2010 between 09.10.2010 and 11.10.2010 (that's so far ok) and 10:00 between 11:00 and 9:00 (no return there, because 10:00 doesn't lie within interval 11:00 -> 9:00... actually no value lies there) ;
Don't you have any other idea?
Thank you
Lukas

Similar Messages

  • SQL Query for date/time

    Hi All,
    I have a table containing data like this
    Person_name Time_spent Date/time
    ABC 5.5 16-sep-10 12:00
    ABC 3 16-sep-10 05:30
    ABC 2.5 17-sep-10 12:00
    ABC .5 16-sep-10 09:00
    What I want is to get data like this
    Person_name Time_spent Date/time
    ABC 9 16-sep-10
    ABC 2.5 17-sep-10
    what query i should run?
    Thanx
    Omy

    a query like this ...
    select sum(time_spent), person_name, trunc(date_time) from <table_name>
    group by person_name, trunc(date_time);
    HTH.

  • SQL Query for Date field updation

    I want a query from u.. Hope u help me with a
    solution soon..
    My Q: I want to update a date field in Oracle
    database. But the condition is that i shouldnt change
    the hours, minutes & seconds of the date field.
    generally , if we update the date field then it takes
    the default values for hours, min's & sec's to
    00:00:00.
    EX : if we have a value 21-SEP-2002 04:54:44 in a date
    field. I want to update it to 22-SEP-2002 04:54:44.
    But it updates to 22-sep-2002 00:00:00 if we use
    UPDATE command.

    Use a PreparedStatement:
    PreparedStatement ps = conn.prepareStatement("SELECT * FROM TEMP WHERE TDATE > ? AND TDATE < ?");
    // note: month numbers start at 0, so 1 is february
    GregorianCalendar c1 = new GregorianCalendar(2002, 1, 11, 11, 0);
    GregorianCalendar c2 = new GregorianCalendar(2002, 1, 18, 22, 0);
    Date d1 = c1.getTime();
    Date d2 = c2.getTime();
    java.sql.Timestamp sqlDate1 = new java.sql.Timestamp(d1.getTime());
    java.sql.Timestamp sqlDate2 = new java.sql.Timestamp(d2.getTime());
    ps.setTimestamp(1, sqlDate1);
    ps.setTimestamp(2, sqlDate2);
    ResultSet rs = ps.executeQuery();
    // get results from the result setJesper

  • SQL Query for DATE

    In my Jsp program, i have 3 schemes, one for 1 month, second for 3 month, and third for 12 month.
    Now an user can create his account and select any of the 3 schemes, what i want is that in my database table there are two columns one is tha startdate colume which holds data for the date posted, ie, current date, and the other column is the enddate which holds data for the expiry date depending on the schemes selected....
    What i want is that when a user register for an account his startdate is the present date and i want a query which automatically calculates the enddate keeping in mind the scheme and update the table with the derived result.
    Thanx :banghead:

    Check out the Calendar API, specially the add method, e.g, for adding 3 days to some date
                Calendar cal = Calendar.getInstance();
                cal.setTime(currentTime);//The current time
                cal.add(Calendar.DATE, 3);//Add 3 days to the current timeCheck the api for adding months instead of days,
    regards,
    Manuel Leiria

  • SQL query for date picker

    On a reports page there are two 2 date picker items ( a datefrom and a dateto) along with a text field with autocomplete item
    When the page loads the following query is called
    SELECT
    "COL1",
    "COL2",
    "COL3",
    from "TABLE"
    WHERE MYDATES BETWEEN :DATEFROM AND :DATETO
    Which returns no records as no dates have been selected.
    How can I alter this so the WHERE clause on the date item searches is called only if and when the dates are chosen, and by default all records are shown.
    The other related issue is when I have selected a from and to date and search when I go back into the report view page after viewing other pages in the apex app, the form fields are still populated, how can I clear the session down for these fields when the user leaves the page?
    Hope this all makes sense?

    To_date('01.01.2100', 'dd.mm.yyyy') is going to give wrong results on 02.01.2100 :D
    A solution (maybe there is a cleaner one...) :
    WHERE
    ((:DATEFROM IS NOT NULL AND mydates >= :DATEFROM) OR :DATEFROM IS NULL)
    AND
    ((:DATETO IS NOT NULL AND mydates <= :DATETO) OR :DATETO IS NULL)You can change the "No data found" message by modifiying the "When No Data Found Message" report attribute.
    EDIT : And for the 2nd issue, Alex is right, but also be aware that Firefox retains form element values on page refresh, you have to switch the "Form Auto Complete" page security attribute to "Off" if you don't want to retain form element values.
    Edited by: Yann39 on 27 juin 2012 06:30

  • SQL Query for real time resource stats

    Does anyone know what the query would be to duplicate the real time resource stats page in version 8 or above of UCCX?  I need to build a custom web page that displays the same information.  I've got all the connectivity to the database just fine and can query it and display information.  Just can't figure out what the SQL would be that would extract that information.

     Michael,
    you can try :
    SELECT x.resourceName, t.eventType, x.datetime FROM (SELECT t1.resourceID, t1.resourceName, MAX(t2.eventDateTime) AS datetime FROM Resource AS t1 INNER JOIN AgentStateDetail AS t2 ON t2.agentID = t1.resourceID GROUP BY t1.resourceID, t1.resourceName ) AS x INNER JOIN AgentStateDetail AS t ON t.agentID = x.resourceID AND t.eventDateTime = x.datetime ORDER BY x.resourceName
    You will need to translate the eventType into the "readable" status like Talking or Not Ready with an IF or Case statement.
    Regards,
    Jeroen

  • Problem writing a sql query for a select list based on a static LOV

    Hi,
    I have the following table...
    VALIDATIONS
    ID          Number     (PK)
    APP_ID          Number     
    REQUESTED     Date          
    APPROVED     Date          
    VALID_TIL     Date
    DEPT_ID          Number     (FK)
    I have a search form with the following field item variables...
    P11_DEPT_ID (select list based on dynamic LOV from depts table)
    P11_VALID (select list based on static Yes/No LOV)
    A report on the columns of the Validations table is shown based on the values in the search form. So far, my sql query for the report is...
    SELECT v.APP_ID,
    v.REQUESTED,
    v.APPROVED,
    v.VALID_TIL,
    d.DEPT
    FROM DEPTS d, VALIDATIONS v
    WHERE d.DEPT_ID = v.DEPT_ID(+)
    AND (d.DEPT_ID = :P11_DEPT_ID OR :P11_DEPT_ID = -1)
    This query works so far. My problem is that I don't know how to do a search based on the P11_VALID item - if 'yes' is selected, then the VALID_TIL date is still valid. If 'no' is selected then the VALID_TIL date has passed.
    Can anyone help me to extend my query to include this situation?
    Thanks.

    Hello !
    Let's have a look at my example:create table test
    id        number
    ,valid_til date
    insert into test values( 1, sysdate-3 );
    insert into test values( 2, sysdate-2 );
    insert into test values( 3, sysdate-1 );
    insert into test values( 4, sysdate );
    insert into test values( 5, sysdate+1 );
    insert into test values( 6, sysdate+2 );
    commit;
    select * from test;
    def til=yes
    select *
      from test
      where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
           =decode('&til','yes',1,-1);
    def til=no
    select *                                                                               
      from test                                                                            
      where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
           =decode('&til','yes',1,-1);  
    drop table test;  It's working fine, I've tested it.
    The above changes to my first idea I did because of time portion of the DATE datatype in Oracle and therefore the wrong result for today.
    For understandings:
    1.) TRUNC removes the time part of DATE
    2.) The difference of to date-values is the number of days between.
    3.) SIGN is the mathematical function and gives -1,0 or +1 according to an negative, zero or positiv argument.
    4.) DECODE is like an IF.
    Inspect your LOV for the returning values. According to my example they shoul be 'yes' and 'no'. If your values are different, you may have to modify the DECODE.
    Good luck,
    Heinz

  • Error while executing a sql query for select

    HI All,
    ORA-01652: unable to extend temp segment by 128 in tablespace PSTEMP i'm getting this error while i'm executing the sql query for selecting the data.

    I am having 44GB of temp space, while executing the below query my temp space is getting full, Expert please let us know how the issue can be resolved..
    1. I dont want to increase the temp space
    2. I need to tune the query, please provide your recomendations.
    insert /*+APPEND*/ into CST_DSA.HIERARCHY_MISMATCHES
    (REPORT_NUM,REPORT_TYPE,REPORT_DESC,GAP,CARRIED_ITEMS,CARRIED_ITEM_TYPE,NO_OF_ROUTE_OF_CARRIED_ITEM,CARRIED_ITEM_ROUTE_NO,CARRIER_ITEMS,CARRIER_ITEM_TYPE,CARRIED_ITEM_PROTECTION_TYPE,SOURCE_SYSTEM)
    select
    REPORTNUMBER,REPORTTYPE,REPORTDESCRIPTION ,NULL,
    carried_items,carried_item_type,no_of_route_of_carried_item,carried_item_route_no,carrier_items,
    carrier_item_type,carried_item_protection_type,'PACS'
    from
    (select distinct
    c.REPORTNUMBER,c.REPORTTYPE,c.REPORTDESCRIPTION ,NULL,
    a.carried_items,a.carried_item_type,a.no_of_route_of_carried_item,a.carried_item_route_no,a.carrier_items,
    a.carrier_item_type,a.carried_item_protection_type,'PACS'
    from CST_ASIR.HIERARCHY_asir a,CST_DSA.M_PB_CIRCUIT_ROUTING b ,CST_DSA.REPORT_METADATA c
    where a.carrier_item_type in('Connection') and a.carried_item_type in('Service')
    AND a.carrier_items=b.mux
    and c.REPORTNUMBER=(case
    when a.carrier_item_type in ('ServicePackage','Service','Connection') then 10
    else 20
    end)
    and a.carrier_items not in (select carried_items from CST_ASIR.HIERARCHY_asir where carried_item_type in('Connection') ))A
    where not exists
    (select *
    from CST_DSA.HIERARCHY_MISMATCHES B where
    A.REPORTNUMBER=B.REPORT_NUM and
    A.REPORTTYPE=B.REPORT_TYPE and
    A.REPORTDESCRIPTION=B.REPORT_DESC and
    A.CARRIED_ITEMS=B.CARRIED_ITEMS and
    A.CARRIED_ITEM_TYPE=B.CARRIED_ITEM_TYPE and
    A.NO_OF_ROUTE_OF_CARRIED_ITEM=B.NO_OF_ROUTE_OF_CARRIED_ITEM and
    A.CARRIED_ITEM_ROUTE_NO=B.CARRIED_ITEM_ROUTE_NO and
    A.CARRIER_ITEMS=B.CARRIER_ITEMS and
    A.CARRIER_ITEM_TYPE=B.CARRIER_ITEM_TYPE and
    A.CARRIED_ITEM_PROTECTION_TYPE=B.CARRIED_ITEM_PROTECTION_TYPE
    AND B.SOURCE_SYSTEM='PACS'
    Explain Plan
    ==========
    Plan
    INSERT STATEMENT ALL_ROWSCost: 129 Bytes: 1,103 Cardinality: 1                                                        
         20 LOAD AS SELECT CST_DSA.HIERARCHY_MISMATCHES                                                   
              19 PX COORDINATOR                                              
                   18 PX SEND QC (RANDOM) PARALLEL_TO_SERIAL SYS.:TQ10002 :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1                                         
                        17 NESTED LOOPS PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1                                    
                             15 HASH JOIN RIGHT ANTI NA PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,098 Cardinality: 1                               
                                  4 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 63 Bytes: 359,283 Cardinality: 15,621                          
                                       3 PX SEND BROADCAST PARALLEL_TO_PARALLEL SYS.:TQ10001 :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621                     
                                            2 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621                
                                                 1 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621           
                                  14 NESTED LOOPS ANTI PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 40,256,600 Cardinality: 37,448                          
                                       11 HASH JOIN PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 6,366,160 Cardinality: 37,448                     
                                            8 BUFFER SORT PARALLEL_COMBINED_WITH_CHILD :Q1002               
                                                 7 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 1 Bytes: 214 Cardinality: 2           
                                                      6 PX SEND BROADCAST PARALLEL_FROM_SERIAL SYS.:TQ10000 Cost: 1 Bytes: 214 Cardinality: 2      
                                                           5 INDEX FULL SCAN INDEX CST_DSA.IDX$$_06EF0005 Cost: 1 Bytes: 214 Cardinality: 2
                                            10 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448                
                                                 9 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448           
                                       13 TABLE ACCESS BY INDEX ROWID TABLE PARALLEL_COMBINED_WITH_PARENT CST_DSA.HIERARCHY_MISMATCHES :Q1002Cost: 0 Bytes: 905 Cardinality: 1                     
                                            12 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT SYS.HIERARCHY_MISMATCHES_IDX3 :Q1002Cost: 0 Cardinality: 1                
                             16 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT CST_DSA.IDX$$_06EF0001 :Q1002Cost: 1 Bytes: 5 Cardinality: 1

  • How to change color of a button for specific time interval in jsp

    How to change color of a button for specific time interval in jsp.
    Please help.
    Thanks in advance.

    This was driving me crazy, too--and the previous answers did not seem to work. I eventually found that if I click one of the data symbols in the graph in exactly the right spot (see below), it selects only the data symbols and not the line. I can tell this because the little selection dots will be around each data symbol, but no selection dots will be on the line between the data symbols - like the graphic in Yvan's answer. Then and only then will the color symbol in the tool bar show the color of the data symbol, instead of the color of the line. I believe that you then have to first click on the color swatch in the toolbar and then select your color (or choose Show Colors and select from the color tool). Just clicking a color in the crayon box, for example, did not seem to work unless I first clicked on the color swatch in the toolbar, then clicked Show Colors on that dropdown, and +only then+ clicked the crayon or whatever.
    _The right spot to click_ seems to be just above the exact center of the data symbol, at least for the diamond shape symbol that I prefer. Sometimes it takes several tries to hit the right spot. If I miss it, the whole line is selected, which is indicated by the little selection dots on the line, between the data symbols. When I click the right spot, those selection dots go away, leaving only the data symbols selected. Then I can change the color, as described above.
    I hope this works for you too.

  • Using CVS in SQL Developer for Data Modeler changes.

    Hi,
    I am fairly new to SQL Developer Data Modeler and associated version control mechanisms.
    I am prototyping the storage of database designs and version control for the same, using the Data Modeler within SQL Developer. I have SQL Developer version 3.1.07.42 and I have also installed the CVS extension.
    I can connect to our CVS server through sspi protocol and external CVS executable and am able to check out modules.
    Below is the scenario where I am facing some issue:
    I open the design from the checked out module and make changes and save it. In the File navigator, I look for the files that have been modified or added newly.
    This behaves rather inconsistently in the sense that even after clicking on refresh button, sometimes it does not get refreshed. Next I try to look for the changes in Pending Changes(CVS) window. According to the other posts, I am supposed to look at the View - Data Modeler - Pending Changes window for data modeler changes but that shows up empty always( I am not sure if it is only tied to Subversion). But I do see the modified files/ files to be added to CVS under Versioning - CVS - Pending Changes window. The issue is that when I click on the refresh button in the window, all the files just vanish and all the counts show 0. Strangely if I go to Tools - Preferences - Versioning - CVS and just click OK, the pending changes window gets populated again( the counts are inconsistent at times).
    I believe this issue is fixed and should work correctly in 3.1.07.42 but it does not seem to be case.
    Also, I m not sure if I can use this CVS functionality available in SQL Dev for data modeler or should I be using an external client such as Wincvs for check in/ check out.
    Please help.
    Thanks

    Hi Joop,
    I think you will find that in Data Modeler's Physical Model tree the same icons are used for temporary Tables and Materialized Views as in SQL Developer.
    David

  • SQL Query Executing longer time

    Hi , The below SQL query executing longer time . Please help to Improve the query performance. The query continuously running for more than 24 hours and failing with roolback segment error. Not getting the final output. Most of the tables are having milions of records.
    Select distinct
    IBS.ADSL_ACCESS_INFO,
    IBS.LIJ ,
    regexp_substr(OBVS.REFERENTIE_A,'[[:digit:]]+') as O_NUMBER,
    DBS.CKR_NUMMER_CONTRACTANT,
    DBS.DNUMBER
    FROM CD.IBS,
    CD.OIBL,
    CD.IH,
    CD.ODL,
    CD.OH,
    CD.DBS,
    CD.OBVS
    Where IBS.END_DT = To_Date('31129999', 'ddmmyyyy')
    AND OIBL.END_DT = to_date('31129999', 'ddmmyyyy')
    AND DBS.END_DT = to_date('31129999', 'ddmmyyyy')
    AND OBVS.END_DT = to_date('31129999', 'ddmmyyyy')
    AND OBVS.REFERENTIE_A LIKE 'OFM%'
    AND OIBL.INFRA_KEY = IH.INFRA_KEY
    AND OIBL.ORDERS_KEY = OH.ORDERS_KEY
    AND IBS.INFH_ID = IH.INFH_ID
    AND ODL.ORDH_ID = OH.ORDH_ID
    AND DBS.DEBH_ID = ODL.DEBH_ID
    AND OBVS.ORDH_ID = ODL.ORDH_ID
    Order By IBS.LIJ
    All the columns which are present in the where condition are having either Index/key (Primary/unique) except END_DT column.
    Please Advise

    Predicate pushing can help when it greatlly restricts the number of rows - you must experiment - might not work with all predicates pushed (as shown here)
    select distinct
           ibs.adsl_access_info,
           ibs.lij,
           obvs.o_number,
           dbs.ckr_nummer_contractant,
           dbs.dnumber
      from (select infh_id,adsl_access_info,lij
              from cd.ibs
             where end_dt = to_date('31129999','ddmmyyyy')
           ) ibs,
           (select infra_key,orders_key
              from cd.oibl
             where end_dt = to_date('31129999','ddmmyyyy')
           ) oibl,
           (select ordh_id,regexp_substr(obvs.referentie_a,'[[:digit:]]+') as o_number
              from cd.obvs
             where end_dt = to_date('31129999','ddmmyyyy')
               and referentie_a like 'OFM%'
           ) obvs,
           (select debh_id,ckr_nummer_contractant,dnumber
              from cd.dbs
             where end_dt = to_date('31129999','ddmmyyyy')
           ) dbs,
           cd.ih,
           cd.odl,
           cd.oh
    where oibl.infra_key = ih.infra_key
       and oibl.orders_key = oh.orders_key
       and ibs.infh_id = ih.infh_id
       and odl.ordh_id = oh.ordh_id
       and dbs.debh_id = odl.debh_id
       and obvs.ordh_id = odl.ordh_id
    order by ibs.lijRegards
    Etbin

  • SQL query generating data in SQL management studio but not in CUIC interface

    Hello,
    I'm working on a UCCE 9.0 system
    I created SQL query for a  report.
    Whenever I run the query inside the SQL management studio, it works and generates data, but when I run it in the CUIC interface it works but generates nothing. As you can see in the below snapshot, it contains 209 records that are not being displayed.
    Any help would be greatly apprciated

    Is it a custom report ? Can you right click on your Custom Report and click on Edit Views. You need to check whether you have Grid Headers Listed.
    Regards,
    Senthil

  • Selction query for date

    i have a interface there user can enter two dates . in my servlet program i am getting it as string by using request .get parameter. i wanan to know how to write sql query for selecting data from database with between clause

    //for example you are getting the date format like 17-Jul-2006 as String
    String strDate1 = "17-Jul-2006";//request.getParameter("date1");
    String strSQL = "SELECT SYSDATE from dual
    WHERE SYSDATE - 10 > to_date('"+date1 +"','dd-mm-yyyy')";
    Hope this example will help you!!!
    Regards,
    AfTaB

  • How to write sql query for counting pairs from below table??

    Below is my SQL table structure.
    user_id | Name | join_side | left_leg | right_leg | Parent_id
    100001 Tinku Left 100002 100003 0
    100002 Harish Left 100004 100005 100001
    100003 Gorav Right 100006 100007 100001
    100004 Prince Left 100008 NULL 100002
    100005 Ajay Right NULL NULL 100002
    100006 Simran Left NULL NULL 100003
    100007 Raman Right NULL NULL 100003
    100008 Vijay Left NULL NULL 100004
    It is a binary table structure.. Every user has to add two per id under him, one is left_leg and second is right_leg... Parent_id is under which user current user is added.. Hope you will be understand..
    I have to write sql query for counting pairs under id "100001". i know there will be important role of parent_id for counting pairs. * what is pair( suppose if any user contains  both left_leg and right_leg id, then it is called pair.)
    I know there are three pairs under id "100001" :-
    1.  100002 and 100003
    2.  100004 and 100005
    3.  100006 and 100007
        100008 will not be counted as pair because it does not have right leg..
     But i dont know how to write sql query for this... Any help will be appreciated... This is my college project... And tommorow is the last date of submission.... Hope anyone will help me...
    Suppose i have to count pair for id '100002'. Then there is only one pair under id '100002'. i.e 100004 and 100005

    Sounds like this to me
    DECLARE @ID int
    SET @ID = 100001--your passed value
    SELECT left_leg,right_leg
    FROM table
    WHERE (user_id = @ID
    OR parent_id = @ID)
    AND left_leg IS NOT NULL
    AND right_leg IS NOT NULL
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Provide sql query for below one

    hi everyone,
    in my source table [finanace_dept] contains two columns [finance_id,r_mature_kd] with 2 million records and sample data given below.
    finance_id r_mature_kd
    1 H
    1 T
    1 T
    2 T
    3 H
    4 S
    4 T
    4 T
    5 X
    6 H
    6 L
    6 L
    6 M
    please provide sql query for below expected output.
    expected output :
    finance_id r_mature_kd
    1 H
    1 T
    4 S
    4 T
    6 H
    6 L
    6 M
    for column finance_id: '1', contains three records, but two distinct r_mature_kd hence it should retrive only two records with H,T
    for column finance_id: '2','3', contains only one record hence this records should not retrive.
    for column finance_id: '6', contains four records, but three distinct r_mature_kd hence it should retrive only two records with H,L,M
    please help on this.

    WITH T(finance_id,r_mature_kd) AS (
    SELECT 1, 'H' FROM DUAL UNION ALL
    SELECT 1, 'T' FROM DUAL UNION ALL
    SELECT 1, 'T' FROM DUAL UNION ALL
    SELECT 2, 'T' FROM DUAL UNION ALL
    SELECT 3, 'H' FROM DUAL UNION ALL
    SELECT 4, 'S' FROM DUAL UNION ALL
    SELECT 4, 'T' FROM DUAL UNION ALL
    SELECT 4, 'T' FROM DUAL UNION ALL
    SELECT 5, 'X' FROM DUAL UNION ALL
    SELECT 6, 'H' FROM DUAL UNION ALL
    SELECT 6, 'L' FROM DUAL UNION ALL
    SELECT 6, 'L' FROM DUAL UNION ALL
    SELECT 6, 'M' FROM DUAL
    SELECT  DISTINCT finance_id,r_mature_kd,C FROM(
    SELECT finance_id,r_mature_kd,COUNT(1) OVER (PARTITION BY finance_id) C
    FROM T
    WHERE C > 1
    ORDER BY 1
    FINANCE_ID
    R_MATURE_KD
    C
    1
    H
    3
    1
    T
    3
    4
    S
    3
    4
    T
    3
    6
    H
    4
    6
    L
    4
    6
    M
    4
    Ramin Hashimzade

Maybe you are looking for

  • Large file on fcpx and trying to export without compressor? want to eventually transfer to dvd?

    I have a fairly large file on fcpx and trying to export it without compressor. I tried this and the .mov file was way too large to eventually burn to a dvd. Can someone please help!! I am very new to this program. Do I need compressor? Or when I shar

  • Image MAP + KM problems =(

    Please, I have an image like a fluxogram and I will put same links on the itens  of this fluxogram but all the time that I click on the image, open in a new window !!! And I can't fix this problem How can i do that ??? Where Exactly I can configure t

  • Flex Builder crashes if Help is opened

    Hi everybody, I've got a nasty problem after I updated to Flex SDK 3.4. Every time I open up the Help Contents, Flex Builder crashes in 5-20 seconds, regardless of what I do. Anyone has the same problem?

  • Mail server offline

    Each time i try to send a new email from my mac account it times out, informing me that it is offline. My mobileme subscription is ok as it still has till next june. I'm also having a problem publishing updates to my iwebsite. can anyone help?

  • Which RAID controller do I choose?

    Hi forum. I'm waiting for my Asus P9X79-E WS board to arrive this week and I will be using RAID 0 with a separate daily backup drive for it. Before I can afford high end RAID controllers like the Areca etc, I will have to use the onboard controllers.