Need help about designing a query.

Dear All,
I have the following table structure
Fields: issue_id, event_id, event_date
One or more events are related to each issue and each event is associated with a date.
There is a huge data in the table and I want to access the last event date of each date.
The resultant table/view should have following fields:
issue_id, last_event_date
Is this possible using a single/multiple queries or I have to do PL/SQL coding?
Please help.
-Sameer

If you are looking for last event date of an issue then a simple group by query should do it.
SELECT issue_id,max(event_date) last_event_date
FROM my_table
GROUP BY issue_id

Similar Messages

  • Help in designing a Query

    Hello Everyone,
       I want you help in designing a query that involve OACT,OJDT,JDT1,OBGT and BGT1
    Actually I want a report that shows accounts Budget quarterly and its expenditure quarterly as well..
    Like shown below
    Account Name
    Budget from Jan to March
    Budget from April to June
    Budget from July to Sept
    Budget from Oct to Dec
    Expenditure from Jan to Mar
    Expenditure from Apr to June
    Expenditure from July to Sept
    Expenditure from Oct to Dec
                     Parameters would be Fiscal Year and Date range and Account name
    Can anyone please help me out in that one
    Thanks in advance

    Looking at the test data I have in these tables, it would appear impossible to join them all in one query without using UDFs...
    They don't share any columns.

  • Need help about Hidden Markov Model model

    I want to make classification for EEG signal using Hidden Markov Model
    algorithm based on neural network.
    plz need help about how to implement this algorithm using LABVIEW.
    if not I want another thing to make classification.
    any one know information about this topic, send me a reply
    thanks

    Have you derrived the HMM that you want to implement?
    If so, post the algorithm and we can provide comments on how to implement it using LabVIEW.
    Message Edited by Ray.R on 04-12-2010 12:54 PM

  • Need help about ref cursor using like table

    Hi Guys...
    I am devloping package function And i need help about cursor
    One of my function return sys_refcursor. And the return cursor need to be
    join another table in database . I don't have to fetch all rows in cursor
    All i need to join ref cursor and another table in sql clause
    like below
    select a.aa , b.cc form ( ref_cursor ) A, table B
    where A.dd = B.dd
    I appeciate it in advance

    My understanding is that you have a function that returns a refcursor and is called by a java app.
    Because this is a commonly used bit of code, you also want to reuse this cursor in other bits of sql and so you want to include it like table in a bit of sql and join that refcursor to other tables.
    It's not as easy as you might hope but you can probably achieve this with pipelined functions.
    Is it a direction that code should be going down? yes, eventually. I like the idea of pulling commonly used bits of code into a SQL statement especially into the WITH section, provided it could be used efficiently by the CBO.
    Is it worth the effort given what you have to do currently to implement it? possibly not.
    what else could you do? construct the sql statement independently of the thing that used it and reuse that sql statement rather than the refcursor it returns?
    Message was edited by:
    dombrooks

  • Need help about boot SUNFIRE V120

    Hi all....
    I need help about how to change boot from boot net to boot disk....
    after i installed sun solaris 10 at my sunfire v120, then reboot the machine ... this sunfire still boot from net not from disk...
    can i change it?
    please i really need help ....
    thanks

    If its booted, try "eeprom boot-device=disk"
    If your at the OBP, "setenv boot-device disk".
    If that doesnt work check the value of "diag-switch?".
    It could be booting off the the diag-device instead

  • Need Help about 3D and revolving in illustrator

    I really need help about 3D, Please tell me that How i create 3D in illustrator
    i want to revolve text or shape around any object like this, any plugin? or other software required for this?
    if somebody know this it will be really help full
       http://rcgrafix.fizwig.com/1452732-large.jpg    
       http://rcgrafix.fizwig.com/1384370-large.jpg
       http://rcgrafix.fizwig.com/1062180-large.jpg
    Thanks
    Arsi

    if links are not working try Copy and paste it in to your browser address bar
    thank you

  • Need help about the SHA Message Digest ? & what is use of Message Diagest ?

    need help about the SHA Message Digest ? & what is use of Message Diagest ?
    1>i have one program of making message digest
    2>which requires two files name
    3>one for input like txt
    4> second is out put file of message digest
    can any one tell what is the use of second generated file .

    MessageDigest md = MessageDigest.getInstance("SHA");
    FileInputStream fis = new FileInputStream(args[0]);
    byte[] b = new byte[1024];
    int readed = -1;
    while((readed = fis.read(b)) > 0)
         md.update(b, 0, readed);
    fis.close();
    FileOutputStream fos = new FileOutputStream(args[1]);
    byte[] d = md.digest();
    StringBuffer sb = new StringBuffer();
    for(int i = 0; i < d.length; i++) {
         String str = Integer.toHexString(d[i] & 0xff);
         sb.append(str.length() < 2 ? "0" + str : str);
    fos.write(sb.toString().getBytes());
    fos.close();

  • Need help about 1015

    need help about 1015 it says connect iphone to itunes on screen i did it but it doesnt work and says unexpected 1015

    Try restoring it: Make sure you are following the instructions in this procedure to the letter.  Here they are, with emphasis on some easily overlooked requirements:
    Disconnect the USB cable from the iPhone, but leave the other end of the cable connected to your computer's USB port.
    Turn off the device: Press and hold the Sleep/Wake button for a few seconds until the red slider appears, then slide the slider. Wait for the device to turn off.If you cannot turn off the device using the slider, press and hold the Sleep/Wake and Home buttons at the same time. When the device turns off, release only the Sleep/Wake button.
    Continue pressing and holding the Home button while you reconnect the USB cable to the device. The device should turn on.
    Note: If you see the "low battery" screen, let the device charge for at least ten minutes to ensure that the battery has some charge, and then start with step 2 again.
    Continue holding the Home button until you see the "Connect to iTunes" screen. When this screen appears (iTunes icon and USB connector) release the Home button.
    If necessary, open iTunes. You should see the "recovery mode" alert ("iTunes has detected a phone in recovery mode").
    Use iTunes to restore the device.
    If you do not see the "Connect to iTunes" screen, try these steps again.
    If you see the "Connect to iTunes" screen but the device does not appear in iTunes, see this article and its related links.
    If you have backed up the iPhone in the past, select the device in iTunes and choose "restore from backup".

  • Hi, Need help about ios7 upgrade, after this upgrade I cannot watch youtube or any video with my Ipad,

    Hi, Need help about ios7 upgrade, after this upgrade I cannot watch youtube or any video with Ipad, and Iphone as well
    I think my wireless rooter's setting has some problem but cannot found anything to solve,
    I can watch if there is another wireless network , I tried this option in another place who has wireless network and I can watch.
    Do you have any idea to do these setting , I dont have any problem when Ipad has 6.1.3 IOS,
    need help
    thanks

    Thanks
    I will and share the result.

  • Need help in design/framework of a project requirements

    Hi there.
    I need some input/design suggestion and/or comments regarding 2 projects that I'm undertaking currently. The project duration is 8 weeks starting now.
    Some background information of the current technology we are using right now. We are using weblogic 7.0 SP2 and our database is ms sqlserver 2000 and/or mysql. The persistance layer/framework we are using is a home grown JDBC framework. We are using only stateless session beans and our client which is a swing ui access the servers side thru webservices via a session facade. We use also Transfer objects on the client and our own DataObjects on the server side. Current consideration is that we can not upgrade to the current weblogic version at this time and can only use java 1.4 and use existing persistence framework we have. I've considered using Spring/Hibernate but it will involve major refactoring on our existing system, which we can not afford right now. But we can augment or add new framework to handle this 2 projects.
    1. The first project is a mass update/creation of orders and order items. In our system the update and creation of order and order items are complicated and perform several validations (e.g. vendor/client is valid; item are valid and have enough to on-hand, etc.) and lookups before we can create/update an order and it's order items. We estimated that process to be around 1.5 - 3.0 secs and typically we will be processing between a few hundreds to about 5000. The max ceiling we put is 10,000.
    Now the requirements are:
    a. Ensure that the process will be completed and in the event of failure (physical or network or power) and recovery to start where it failed and start processing from that point of failure.
    b. The transaction should be atomic on per order basis and not on whole process - meaning we will commit all changes for an order and start a new transaction on the next order. This will ensure that we have a complete order committed.
    c. Don't tie the client from this process and when the process is finished give a feedback to the client who invoke the process.
    2. The second project is related to the first, is that before they post the process above, the user will look at the set of data and do some editing and then post the data. So this project is on the UI side and would present the user a table/grid view of the data and since data set could be large, we want our swing ui to fetch only a set of rows/data so that it does not take so long to load all the data or run out of memory. A button or by the user scrolling on the scrollbar would fetch the next succeeding rows/data. The problem we have as stated on the first paragraph is these- we are using webservices and stateless session beans and there is no way that the server can recognized who the user is when that user request the next set of row/data set without querying the database again.
    So your input and help is very much appreciated and if you know an existing framework that would help me is most welcome.
    Have a blessed day.
    Jun Victorio

    Take the statistics of the tables and check again.
    begin
    DBMS_STATS.gather_table_stats(ownname=>'syslog',tabname=>'logs');
    end;
    Regards
    Asif Kabir

  • Need Help about Spatial Data Load - Mapviewer

    Hello everybody,
    I need an immediate help about spatial data load. I installed Oracle mapviwer quick start and try to work on it. However, I could not pass the load step. My questions are;
    1- Where can I find and download my country's data set (spatial data)
    2- With mapviwer, how can I load spatial data to my tables on database (Oracle). Those tables have sdo_geometry columns and I want to query location data, but could not load
    Regards,
    Dilek

    For Mapviewer questions, please post in the following forum:
    MapViewer
    Thanks

  • Need help tuning slow running query

    Need help tuning below two Oracle queries:
    Query #1:
    ======================
    SELECT "WORK_ORDER_FACT_ALL_YESTERDAY"."WORK_ORDER_HISTORY_ID",
    "WORK_ORDER_FACT_ALL_YESTERDAY"."ACCOUNT_NUMBER",
    "ACCOUNT_DIM"."ACCOUNT_NUMBER", "ACCOUNT_DIM"."ACCOUNT_WS_DISC_DATE"
    FROM "CDWD"."WORK_ORDER_FACT_ALL_YESTERDAY" "WORK_ORDER_FACT_ALL_YESTERDAY",
    "CDWD"."ACCOUNT_DIM" "ACCOUNT_DIM"
    WHERE (SUBSTR ("WORK_ORDER_FACT_ALL_YESTERDAY"."ACCOUNT_FIRST_NAME", 1, 1) =
    SUBSTR ("ACCOUNT_DIM"."ACCOUNT_FIRST_NAME", 1, 1)
    AND (SUBSTR ("WORK_ORDER_FACT_ALL_YESTERDAY"."ACCOUNT_LAST_NAME", 1, 4) =
    SUBSTR ("ACCOUNT_DIM"."ACCOUNT_LAST_NAME", 1, 4)
    AND ("WORK_ORDER_FACT_ALL_YESTERDAY"."ACCOUNT_DL_NUMBER" =
    "ACCOUNT_DIM"."ACCOUNT_DL_NUMBER"
    AND "WORK_ORDER_FACT_ALL_YESTERDAY"."WO_TYPE_CODE" IN ('25', '27')
    AND ("ACCOUNT_DIM"."REVENUE_TYPE_ID" = 1)
    AND ("WORK_ORDER_FACT_ALL_YESTERDAY"."TRANSFER_COUNT" = 0)
    AND ("WORK_ORDER_FACT_ALL_YESTERDAY"."WINBACK_ADD_COUNT" = 0)
    AND ("ACCOUNT_DIM"."ACCOUNT_WS_ENTRY_DATE" <
    (TO_DATE ('2006.05.02', 'yyyy.mm.dd') - 11
    AND ("WORK_ORDER_FACT_ALL_YESTERDAY"."IS_DERIVED" = 0)
    AND ("ACCOUNT_DIM"."EXPIRATION_DATE" IS NULL)
    AND ("WORK_ORDER_FACT_ALL_YESTERDAY"."ACT_ACCOUNT_TYPE_CD" <> '50');
    Query #2
    ==================
    UPDATE work_order_fact_all_yesterday g
    SET returns_count = 1
    WHERE EXISTS (SELECT 1
    FROM (SELECT a.phone_dim_key AS transactional_phone_dim_key,
    b.mdn_number AS transactional_mdn_number,
    b.account_number AS transactional_account_number
    FROM work_order_fact_all_yesterday a INNER JOIN phone_dim b ON a.phone_dim_key = b.phone_dim_key
    WHERE a.gross_deactivations_count = 1) e
    INNER JOIN (SELECT c.phone_dim_key AS historical_phone_dim_key,
    d.mdn_number AS historical_mdn_number,
    d.account_number AS historical_account_number
    FROM (SELECT phone_dim_key
    FROM work_order_activity_fact
    WHERE gross_adds_count = 1
    AND report_date >= :b1 - 66
    AND NVL (is_derived, 0 ) = 0
    UNION
    SELECT phone_dim_key
    FROM work_order_fact_all_yesterday
    WHERE gross_adds_count = 1
    AND is_derived = 0) c
    INNER JOIN phone_dim d ON c.phone_dim_key = d.phone_dim_key ) f
    ON e.transactional_mdn_number = f.historical_mdn_number
    AND e.transactional_account_number = f.historical_account_number
    WHERE e.transactional_phone_dim_key = g.phone_dim_key)
    AND g.gross_deactivations_count = 1
    AND g.account_revenue_type_id = 1;
    I ran the DBMS_SQLTUNE on it for 10g and did not get any advice. How can I tune the above queries? Thanks!

    Tune the SQL? Looking at the join criteria of SUBSTR("WORK_ORDER_FACT_ALL_YESTERDAY"."ACCOUNT_FIRST_NAME", 1, 1) = SUBSTR ("ACCOUNT_DIM"."ACCOUNT_FIRST_NAME", 1, 1) and other substrings, it seems to me that you have basic flaws in your relation design.
    Column must be atomic values. Having to extract a sub-set value from a column to create the intelligence needed to join to another table - that is just plain wrong in relation design. Never mind the performance impact and overheads it causes in the database.

  • Need help in the following query

    Hi ,
    I have the following query to pull out data for a particular timeperiod( campaign)
    select
    da.acct_nr,smas.mrkt_id,smas.fld_sls_cmpgn_perd_id,smas.acct_key,smas.upln_acct_key,smas.awrd_sls_amt,smas.fld_net_sls_amt
    ,smas.stf_ind,da1.acct_nr,
    smas.fld_sls_cmpgn_perd_id,smas.acct_key,smas.upln_acct_key,smas.awrd_sls_amt,smas.fld_net_sls_amt
    ,smas.stf_ind,da1.acct_nr,prev.*
    From cdw.sum_mrkt_acct_sls smas
    join codi.dim_acct da
    on (smas.mrkt_id = da.mrkt_id and smas.acct_key = da.acct_key)
    join codi.dim_acct da1
    on (smas.mrkt_id = da1.mrkt_id and smas.UPLN_acct_key = da1.ACCT_KEY)
    where smas.acct_key in
    select dwnln_acct_key from codi.dim_ldrshp_genlgy
    where mrkt_id = 66 and fld_sls_cmpgn_perd_id = 20100304
    and root_upln_acct_key = (select acct_key from codi.dim_acct where acct_nr = '0032622' and mrkt_id = 66)
    and
    smas.mrkt_id = 66
    and smas.fld_sls_cmpgn_perd_id = 20100304
    and smas.sls_org_key <> -100
    order by 1
    So this query will pull out data for campaign 20100304
    No i want to modify the query to pull out data for 3 such campaigns.
    for a smas.acct_key
    so data will
    smas.acct_key all the data for 1st campaign , all the data for 2nd campaign. all the data for 3rd campaign
    Could you please help in modifying this query.
    Thanks

    How about this ??
    select da.acct_nr,
           smas.mrkt_id,
           smas.fld_sls_cmpgn_perd_id,
           smas.acct_key,
           smas.upln_acct_key,
           smas.awrd_sls_amt,
           smas.fld_net_sls_amt,
           smas.stf_ind,
           da1.acct_nr,
           smas.fld_sls_cmpgn_perd_id,
           smas.acct_key,
           smas.upln_acct_key,
           smas.awrd_sls_amt,
           smas.fld_net_sls_amt,
           smas.stf_ind,
           da1.acct_nr,
           prev.*
      From cdw.sum_mrkt_acct_sls smas
      join codi.dim_acct da on (smas.mrkt_id = da.mrkt_id and
                               smas.acct_key = da.acct_key)
      join codi.dim_acct da1 on (smas.mrkt_id = da1.mrkt_id and
                                smas.UPLN_acct_key = da1.ACCT_KEY)
    where smas.acct_key in (select dwnln_acct_key
                               from codi.dim_ldrshp_genlgy
                              where mrkt_id = 66
                                and fld_sls_cmpgn_perd_id in( 20100304,20100305,20100306)
                                and root_upln_acct_key =
                                    (select acct_key
                                       from codi.dim_acct
                                      where acct_nr = '0032622'
                                        and mrkt_id = 66))
       and smas.mrkt_id = 66
       and smas.fld_sls_cmpgn_perd_id in( 20100304,20100305,20100306)
       and smas.sls_org_key - 100
    order by 1

  • Need help in insert statment query

    Hi,
    I have a table T1 with values like
    col1
    1
    2
    3
    4
    I need to write insert statment for t2 as
    insert into t2(col1,col2) values ('AA',select col1 from t1);
    The output of T2 should be
    col1 col2
    AA 1
    AA 2
    AA 3
    AA 4
    Any help in modifying the query.
    Ashish

    What is wrong with this?
    INSERT INTO id_own_dw.id_t_dw_org_dq_tgt
           (cost_center_cod_vc_old,
            cost_center_cod_vc_new
         SELECT '3016052',<<<_-- this you can replace with your varibale in pl/sql block
                cost_center_cod_vc
           FROM id_own_dw.id_t_dw_msl_org_cctr2mkdiv
          WHERE busi_unit_cod_vc = '3016496'

  • Need help in refining the query

    Hello Experts,
    Need your help in refining the query further more.
    table structure 
    Mskey  Col A Col B
    1   empno [20141127-20151128]1234
    1   empno [20151201-99991231]232544
    1   salutation [20141127-99991231]Mrs
    1   salutation [20151127-99991231]Mr
    2   empno [20141127-20151128]1234
    2   empno [20151201-99991231]232544
    2   salutation [20141127-99991231]Mrs
    2   salutation [20151127-99991231]Mr
    My requirement is to find the list of overlapping records based on the dates
    user details may be varying from time to time as new data would be pushed through HR systems to identity store via an interface.
    The job is getting failed whenever there is any overlapping with dates. So we proactively decided to schedule a job in this regards which runs weekly and would let us know for which and all the users there is overlapping dates are there, so that we can send the list to HR team for pushing new data.
    Overlapping Issue Example:
    The users employee id for an year it is 1234 and later he moved to another department and his employee id got changed and it became 2345 remaining all details are same. So the HR systems send the data for this user as empno - [20141127-20151128]1234 and empno - [20151201-99991231]232544
    it means from 20141127 to 20151128 his employee no is 1234 and from 20151201 to 99991231 his employee would be 2345.
    This is a correct case and the tool would accept this data.
    the below cases are invald
    Case 1: 1 salutation [20141127-99991231]Mrs 1 salutation [20151127-99991231]Mr
    Case 2: 2 salutation [20141127-99991231]Mrs 2 salutation [20141127-99991231]Mr
    So we wanted to find these overlapping records from tables.
    My Query:
    I am able to successfully write query for the case 2 type but unable to write for case1.
    select id,colA
    count(left(ColB,CHARINDEX(']',ColB))) as 'Count'
    from tblA with (nolock)
    where id in (Select distinct id from tblb with (nolock))
    group by id, cola,left(ColB,CHARINDEX(']',ColB))
    having count(left(ColB,CHARINDEX(']',ColB)))>1

    Finally got the required answer with the below query
    WITH Cte AS
    SELECT ID,ColA,ColB,ROW_NUMBER() OVER(ORDER BY (SELECT 1)) AS RN,
    CAST(SUBSTRING(ColB,2,CHARINDEX('-',ColB)-2) AS DATE) AS StartDT,
    CAST(SUBSTRING(ColB,CHARINDEX('-',ColB)+1,8) AS DATE)  AS EndDT  FROM TblA
    SELECT c1.ID, c1.ColA,c1.ColB
    FROM Cte c1 JOIN Cte c2
    ON c1.RN != c2.RN
    AND c1.ID=c2.ID
    AND c1.ColA=c2.ColA
    AND (c1.StartDT BETWEEN c2.StartDT AND c2.EndDT OR c2.StartDT BETWEEN c1.StartDT AND c1.EndDT )

Maybe you are looking for