Select the first or last row of sql Command

Hello

I am trying to get the fist or the last line of output from sql below

SQL> set head off;
SQL> select  r.actual_start_date,r.phase_code,r.status_code,r.actual_completion_date from
  2      apps.fnd_concurrent_programs_vl p, apps.fnd_concurrent_requests r
   where p.concurrent_program_id = r.concurrent_program_id
  3    4      and p.application_id = r.program_application_id
  5      and p.user_concurrent_program_name like 'Purge Concurrent Request and/or Manager Data'
  6  and  r.actual_start_date >= sysdate-7
--and rownum<1
  7    8  --order by r.requested_start_date
  9  ORDER BY r.actual_completion_date DESC;


29-DEC-13          C C 29-DEC-13
28-DEC-13          C C 28-DEC-13
27-DEC-13          C C 27-DEC-13
26-DEC-13          C C 26-DEC-13
25-DEC-13          C C 25-DEC-13
24-DEC-13          C C 24-DEC-13
23-DEC-13          C C 23-DEC-13


7 rows selected.


SQL> select  r.actual_start_date,r.phase_code,r.status_code,r.actual_completion_date from
  2      apps.fnd_concurrent_programs_vl p, apps.fnd_concurrent_requests r
   where p.concurrent_program_id = r.concurrent_program_id
  3    4      and p.application_id = r.program_application_id
  5      and p.user_concurrent_program_name like 'Purge Concurrent Request and/or Manager Data'
  6  and  r.actual_start_date >= sysdate-7
  7  and rownum<2
  8  --order by r.requested_start_date
  9  ORDER BY r.actual_completion_date DESC;



27-DEC-13          C C 27-DEC-13






SQL> select  r.actual_start_date,r.phase_code,r.status_code,r.actual_completion_date from
  2      apps.fnd_concurrent_programs_vl p, apps.fnd_concurrent_requests r
   where p.concurrent_program_id = r.concurrent_program_id
  3    4      and p.application_id = r.program_application_id
  5      and p.user_concurrent_program_name like 'Purge Concurrent Request and/or Manager Data'
  6  and  r.actual_start_date >= sysdate-7
  7  and rownum<1
  8  --order by r.requested_start_date
  9  ORDER BY r.actual_completion_date DESC;


no rows selected


SQL>

I want to get the last run of the program which is the first line of the top of the output of sql. (which is December 29, 13, first row on top of the exit)

But if I use the condition as ' where rownum < 1, its not giving any output, if I use where rownum < 2, if you do not have out. "

Grateful if someone can help.

-Thank you

Vijay...

Hi Vijay,

The following should work...

ROWNUM< 1="" will="" not="" retrieve="" any="" rows="" as="" rownum="" values="" start="" with="" 1.="" to="" get="" the="" desired="" result="" you="" have="" to="" build="" the="" result="" set,="" order="" it="" and="" then="" select="" the="" desired="">

SELECT *.

Of

(SELECT r.actual_start_date,

r.phase_code,

r.status_code,

r.actual_completion_date

Apps.fnd_concurrent_programs_vl p,

Apps.FND_CONCURRENT_REQUESTS r

WHERE p.concurrent_program_id = r.concurrent_program_id

AND p.application_id = r.program_application_id

AND p.user_concurrent_program_name LIKE 'Serve concurrent demand and/or Manager Data'

AND r.actual_start_date > = sysdate-7

-Order of r.requested_start_date

ORDER BY r.actual_completion_date DESC

)

WHERE rownum< 2="">

I hope this helps.

VR,

Sudhakar

Tags: Database

Similar Questions

  • It is possible to select more than one layer by selecting the first and the last layers?

    I frequently get Illustrator files which are individual objects such as the paths on separate layers that can be grouped together to make the shorter layers. I find that I have to change click on each individual layer to select it to finally bring together them. Sometimes, I have 25 or so layers that I need to select. Is there a way to select the first and the last layer in the layers palette and have Illustrator select all the layers in the meantime?

    Don't know about the selection of layers of first/last, but to select several consecutive layers in the layers palette...

    Option-click on (Mac) on a layer to select it and, with the option always pressed key, drag to the bottom of the list - DO NOT slip on as logical target icons you like.  When you drag to the bottom of the list of layers, the icons of the target will become selected.

    Shift + Option-click allows you to ignore the layers and continue to select consecutive additional layers on the bottom of the palette.

    Note: Drag slowly or some layers would not choose.

    Strange, I know.  It took me years to come across this.

  • Need a query to return the first and last date for a rowset.

    Hello

    I have a query which can be simplified to the following data, if
    Assume that it is my dataset, with THE_VALUE of
    Sign (Anum) therefore,-1, 0 or 1.

    * (Sorry for crushed registration. "I can't understand this website's rich text formatting.) *

    THE_VALUE THE_DATE THE_MEMBER
    1 0 1 January 2007
    1 0 1 February 2007
    1 0 1 March 2007
    1. 1 April 1, 2007
    1 1 1 May 2007
    1 0 1 June 2007
    1. 1 July 1, 2007
    1. 1 August 1, 2007
    1 0 01 - sep - 2007
    2 0 1 January 2007
    2 1 February 1, 2007
    2 0 1 March 2007
    2. 1 April 1, 2007
    2 1 1 May 2007
    2 0 1 June 2007
    -2 1 1 July 2007
    2. 1 August 1, 2007
    2. 1 01-sep-2007
    3 0 1 January 2007
    3. 1 February 1, 2007
    3 0 1 March 2007
    3 0 1 April 2007
    3. 1 May 1, 2007
    3 0 1 June 2007
    3. 1 July 1, 2007
    3. 1 August 1, 2007
    3 0 01 - sep - 2007

    I need to get the lines with the THE_MEMBER, the values of the first and the last
    THE_DATE, where the value is - 1, and the date range is the last
    set of lines to the Member, with the same value of THE_VALUE.

    I tried the following to get the dates of first and last for a set
    consecutive months with the same value for the Member.

    SELECT the_member
    the_value
    the_date
    first_value (the_date)
    in the first_date (PARTITION the_member, ORDER BY the_member the_value, the_date)
    last_value (the_date)
    during the last_date (PARTITION the_member, ORDER BY the_member the_value, the_date)
    OF togola
    ORDER BY the_member
    the_date;

    At first, it seems to work, but then, when the return value
    an old value, FIRST_DATE will be the first of all the lines containing
    This value for the Member rather than the first of consecutive
    rows with this value for the Member. Apparently the partitioning
    occurs before the order.

    THE_MEMBER THE_VALUE THE_DATE FIRST DATE LAST DATE
    1 0 January 1, 2007 January 1, 2007 January 1, 2007
    1 0 1 February 2007 1 January 2007 1 February 2007
    1 0 1 March 2007 1 January 2007 March 1, 2007
    1. 1 April 1, 2007 April 1, 2007 April 1, 2007
    1. 1 May 1, 2007 April 1, 2007 may 1, 2007
    1-0 June 1, 2007 January 1, 2007 June 1, 2007
    1. 1 July 1, 2007 April 1, 2007 July 1, 2007
    1. 1 August 1, 2007 April 1, 2007 August 1, 2007
    1 0 01 - sep - 2007 1 January 2007 01-Sep-2007

    2 0 January 1, 2007 January 1, 2007 January 1, 2007
    2 1 1 February 2007 February 1, 2007 February 1, 2007
    2 0 1 March 2007 1 January 2007 March 1, 2007
    2. 1 April 1, 2007 February 1, 2007 April 1, 2007
    2 1 1 May 2007 February 1, 2007 may 1, 2007
    2-0 June 1, 2007 January 1, 2007 June 1, 2007
    -2 1 1 July 2007 February 1, 2007 July 1, 2007
    2. 1 August 1, 2007 February 1, 2007 August 1, 2007
    2. 1 01-sep-2007 1 February 2007 01-Sep-2007

    3 0 January 1, 2007 January 1, 2007 January 1, 2007
    3. 1 February 1, 2007 February 1, 2007 February 1, 2007
    3 0 1 March 2007 1 January 2007 March 1, 2007
    3 0 April 1, 2007 January 1, 2007 April 1, 2007
    3. 1 May 1, 2007 February 1, 2007 may 1, 2007
    3 0 June 1, 2007 January 1, 2007 June 1, 2007
    3. 1 July 1, 2007 February 1, 2007 July 1, 2007
    3. 1 August 1, 2007 February 1, 2007 August 1, 2007
    3 0 01 - sep - 2007 1 January 2007 01-Sep-2007

    That's what I need to get in the end.

    THE_MEMBER FIRST DAY DATE OF LAST
    July 2 1 2007-01 - Sep - 2007

    Any ideas would be really appreciated.

    Published by: user10700981 on December 17, 2008 13:57

    Hello

    We'll call the lines whose the_value =-1 'good' lines and lines with the_value! =-1 ranks of 'bad '.

    For each value of the_value, we need the first and last values of the_date where
    the last row in the group is good
    (b) the current line is good
    (c) there is a lot of lines from the current line to the end of the Group
    Condition (a) is just a special case of (c).
    Conditions (b) and (c) are similar: (b) if applied to the current line, (c) applies to all lines after him. They can easily be combined into a single test that counts the number of lines after the current line or bad.

    Which produces the results you requested of the sample data that you provided:

    WITH     count_bad     AS
    (
         SELECT     the_member
         ,     the_date
         ,     COUNT     ( CASE
                        WHEN  the_value != -1 -- assuming the_value is never NULL
                        THEN  1
                     END
                   ) OVER     ( PARTITION BY     the_member
                          ORDER BY     the_date     DESC
                        )     AS bad_cnt
         FROM     table_x
    )
    SELECT     the_member
    ,     MIN (the_date)     AS first_date
    ,     MAX (the_date)     AS last_date
    FROM     count_bad
    WHERE     bad_cnt     = 0
    GROUP BY     the_member
    ORDER BY     the_member;
    
  • Impossible to print the first and last pages of a pdf of the 8 page?

    I have a pdf of 8 pages exported from an InDesign document. I can print it without any problem on my MAC, but when I will forward it to a partner, she is unable to print the first and last pages. Any ideas?

    Hi jimr67163466,

    Could you please let us know the version of Adobe Reader is installed on the machine?

    What operating system is installed on the machine-Windows/Mac?

    The pdf is printing via a network printer?

    This phenomenon happens with a specific document only or with other documents as well?

    Try to print the pdf as image, launch Adobe Reader, click Print > select your printer from the drop-down > click on advanced > check the print as Image > and then click OK.

    Let us know if it worked.

    Thank you

    Shivam

  • Can only see the first and last frame of the item in the editing HELP PLEASE

    Hi, my first time and I find an answer, but fails. I first elements 4 and I'm trying to worm. 9. in version 4 clips in the timelin shows all the frames, but in ver 9 it only shows the first and last frame clips. Is it possible to make all the images to display. I mean by "all frames", clips from filling with frames. I wanted to see all of the images in the scenario, it is easier for me to select and cut the pieces on.

    My features are Core 2 Duo 6750, Nvidia 8600GTS, 4 G of Ram and Vista Home Premium. 3 HARD DRIVE 3 TB.

    Thank you for having responded

    Werner

    Werner,

    Welcome to the forum.

    In the header of the video track, there is an icon for Clip thumbnail display. It's a cycle, and you can scroll through the Modes to display the first frame, first & last, all, or none (name of file only). In pre 4.0, it's on the far left in the header of the track. I guess that's about the same place in pre 9.0.

    Good luck and hope that helps.

    Hunt

  • Popup lov (retrieves the filters and the first set of rows) returns the id

    Hello

    I have a problem when using a popup lov (retrieves the filters and the first set of rows). My LOV is a list of people posting their names, and it works very well when the popup opens. But in the "textfield" showing that you have chosen the corresponding id is displayed. This is not what I want. I want the name to be displayed.

    Any help would be greatly appreciated,

    Bram.

    Bram

    The text field is filled in with the return value.

    If you have

    SELECT name, id
    FROM table
    

    ID will be returned to the text field. If you want the name displayed, then it should be...

    SELECT name a, name b
    FROM table
    

    If you want to use the ID later, behind the scenes, then you could calculate it according to the name.

    See you soon

    Ben

  • Changed the display pad and how can I change this back to the first and last frame of the clip in question?

    Hi, when you cut a clip using the standard cursor (not the adjustment tool but just the mouse), the behavior that I was accustomed to is it shows the first and last frame of the clip you're carved, in a 2 - up window. Now in the updated 2015 I'm confused because it's still place 2 window, but instead I see the head or tail of any clip is next to any side of the clip, I'm trying to cut. I can see the utility in this, but I would like to know where I can go to the screen more as I'm used to it...

    Thank you!

    Click on the key in the timeline and in the drop-down the menu uncheck Composite overview over the filling.

    MtD

  • Select the first 20 days of the month for a given date

    Hi gurus,

    Please let me know to select the first 20 dates for a date supplied by using a parameter.

    For ex -.

    Suppose I provided a date by using a parameter - January 13, 2012

    The query should return me - 01-Jan-2012, January 2, 2012... January 20, 2012

    or if I get home on 23 March 2012

    The query should return me - 01-Mar-2012, March 2, 2012... 20 March 2012

    Thanks in advance.

    Hello

    Here's one way:

    VARIABLE  target_date     VARCHAR2 (11)
    EXEC     :target_date := '13-Jan-2012';
    
    SELECT      TO_DATE ( SUBSTR (:target_date, 4)
                , 'Mon-YYYY'
               ) + LEVEL - 1     AS a_date
    FROM     dual
    CONNECT BY     LEVEL     <= 20
    ;
    

    Note that this does not take account the part of: target_date that represents the day of the month. When you use TO_DATE without giving a date of the month, it defaults to the 1st of the month.

  • Detect the first and last spark of list items

    Hello

    I have a converter item personalized with a background image for each item in a list. the thing is I'm trying to have a different background for the first and last elements (curved respectively) and I don't know how to do this.

    Any help will be appreciated.

    not sure it's the best solution, but:

    You can override the method to data defined in your itemRenderer. Compare the new data for the first and last items in your list. And you set the background depending on the result.

  • SQL: How to select the first telephone number for the Service to find?

    Hi, can someone help me difficulty this query?

    The problem is - ID is left with no phone number, a phone number and phone number. My requirement is to choose only first phone numbers and NULL values if a party who has more than one phone number. The query below is correctly picking of NULL values and unique phone numbers but also by selecting all the phone numbers for the id of group 13909 which has 3 phone numbers

    It involves choosing the first phone number 416-890-0089 and limited to 416-960-8686, 647-456-3040

    How to select only the first group id for the parties who have more than one phone number

    Thanks in advance!

    Select distinct p.party_id,
    p.family_name,
    p.given_name,
    p.Status,
    p.type,
    above. Value,
    PR. Role,
    ad.unit_number,
    ad.unit_identifier,
    ad.street_number,
    ad.street_number_suffix,
    ad.street_name,
    ad.street_type,
    ad.street_direction,
    ad. City,
    ad.province_id,
    ad.Postal_Code,
    ad. Country_ID,
    ad.postal_box_number,
    ad.station_type,
    ad.station_identifier,
    ad.address_line_1,
    ad.address_line_2,
    ad.address_line_3,
    ad.rural_route_identifier,
    ad.rural_route_type,
    ad. Status,
    ad. ADDRESS_ID,
    ad.attention

    part p, ad address this contact_information, party_contact pc, pd, pr SR1CUST1.party_role party_address

    Where
    P.party_id = PD. Party_id
    AND AD.address_id = PD.address_id
    and p.party_id = pr.party_id
    And (CI. Contact_Mode 't ='
    Or CI. Contact_Mode is null)
    AND P.party_id = PC. Party_id (+)
    And PC. CONTACT_INFO_ID = this .contact_info_id (+)
    AND AD.address_type = 'P '.
    and P.type = 'B'
    and pr.role = 'C '.
    and p.family_name like '% Lew '.
    and as p.given_name ' J %
    Order by p.party_id ASC


    Response


    1478 null
    1479 null
    1577 null
    1712 null
    1822 null
    6346-647-345-7384
    6347 416-890-9384
    6348 519-897-0089
    6832 416-930-1265
    8733 647-976-8923
    13909 416-890-0089
    13909 416-960-8686
    13909 647-456-3040

    You can simply use one group from all other columns that the phone number and then choose the min (phone_number):

    select col1,
             col2,
             ...
             coln,
             min(phone_number_column)
    from yourtables
    where yourconditions
    group by col1,
                 col2,
                 ...
                 coln;
    
  • Find the first and last record in a game and the calculation of time

    I have the following table and data below,

    CREATE TABLE AAA_CDR
    (ACCTTYPE (1) NUMBER, MSID VARCHAR2(20 BYTE), ACCOUNTSESSION_ID VARCHAR2(64 BYTE), BEGINNINGSESSION NUMBER (1),)
    SESSIONCONTINUE NUMBER (1), ACCT_MULTI_SESSION_ID VARCHAR2(64 BYTE), DATAOCTETCOUNTORIGINATING NUMBER (20), DATAOCTETCOUNTTERMINATING NUMBER (20), ACCTSESSIONTIME NUMBER (20));

    -SQL statement that produces these data:
    / * Select msid, accountsession_id, beginningsession, sessioncontinue, ACCTTYPE, acct_multi_session_id,.
    dataoctetcountoriginating, dataoctetcountterminating, acctsessiontime
    OF AAA_CDR
    where msid = "5C4CA98EAC4C."
    ORDER BY acct_multi_session_id, accountsession_id, accttype
    */

    Insert into AAA_CDR (ACCTTYPE, MSID, ACCOUNTSESSION_ID, BEGINNINGSESSION, SESSIONCONTINUE, ACCT_MULTI_SESSION_ID, DATAOCTETCOUNTORIGINATING, DATAOCTETCOUNTTERMINATING, ACCTSESSIONTIME)
    Values (1, '5C4CA98EAC4C', '190001E9', 1, 0, '100014E19775F169', 0, 0, 0);
    Insert into AAA_CDR (ACCTTYPE, MSID, ACCOUNTSESSION_ID, BEGINNINGSESSION, SESSIONCONTINUE, ACCT_MULTI_SESSION_ID, DATAOCTETCOUNTORIGINATING, DATAOCTETCOUNTTERMINATING, ACCTSESSIONTIME)
    Values (2, '5C4CA98EAC4C', '190001E9', 0, 0, '100014E19775F169', 47496, 182054, 70);
    Insert into AAA_CDR (ACCTTYPE, MSID, ACCOUNTSESSION_ID, BEGINNINGSESSION, SESSIONCONTINUE, ACCT_MULTI_SESSION_ID, DATAOCTETCOUNTORIGINATING, DATAOCTETCOUNTTERMINATING, ACCTSESSIONTIME)
    Values (1, '5C4CA98EAC4C', ' 290001C 4', 1, 0, '100014E19E21F16C', 0, 0, 0);
    Insert into AAA_CDR (ACCTTYPE, MSID, ACCOUNTSESSION_ID, BEGINNINGSESSION, SESSIONCONTINUE, ACCT_MULTI_SESSION_ID, DATAOCTETCOUNTORIGINATING, DATAOCTETCOUNTTERMINATING, ACCTSESSIONTIME)
    Values (2, '5C4CA98EAC4C', ' 290001C 4', 0, 0, '100014E19E21F16C', 3278162, 17540714, 14152);
    Insert into AAA_CDR (ACCTTYPE, MSID, ACCOUNTSESSION_ID, BEGINNINGSESSION, SESSIONCONTINUE, ACCT_MULTI_SESSION_ID, DATAOCTETCOUNTORIGINATING, DATAOCTETCOUNTTERMINATING, ACCTSESSIONTIME)
    Values (1, '5C4CA98EAC4C', 190001 FC', 1, 0, '100014E1A949316E', 0, 0, 0);
    Insert into AAA_CDR (ACCTTYPE, MSID, ACCOUNTSESSION_ID, BEGINNINGSESSION, SESSIONCONTINUE, ACCT_MULTI_SESSION_ID, DATAOCTETCOUNTORIGINATING, DATAOCTETCOUNTTERMINATING, ACCTSESSIONTIME)
    Values (2, '5C4CA98EAC4C', 190001 FC', 0, 1, "100014E1A949316E", 682734, 2935111, 1553);
    Insert into AAA_CDR (ACCTTYPE, MSID, ACCOUNTSESSION_ID, BEGINNINGSESSION, SESSIONCONTINUE, ACCT_MULTI_SESSION_ID, DATAOCTETCOUNTORIGINATING, DATAOCTETCOUNTTERMINATING, ACCTSESSIONTIME)
    Values (1, '5C4CA98EAC4C', '190001FD', 0, 0, '100014E1A949316E', 0, 0, 0);
    Insert into AAA_CDR (ACCTTYPE, MSID, ACCOUNTSESSION_ID, BEGINNINGSESSION, SESSIONCONTINUE, ACCT_MULTI_SESSION_ID, DATAOCTETCOUNTORIGINATING, DATAOCTETCOUNTTERMINATING, ACCTSESSIONTIME)
    Values (2, '5C4CA98EAC4C', '190001FD', 0, 1, "100014E1A949316E", 1821052, 9585090, 5368);
    Insert into AAA_CDR (ACCTTYPE, MSID, ACCOUNTSESSION_ID, BEGINNINGSESSION, SESSIONCONTINUE, ACCT_MULTI_SESSION_ID, DATAOCTETCOUNTORIGINATING, DATAOCTETCOUNTTERMINATING, ACCTSESSIONTIME)
    Values (1, '5C4CA98EAC4C', '190001FE', 0, 0, '100014E1A949316E', 0, 0, 0);
    Insert into AAA_CDR (ACCTTYPE, MSID, ACCOUNTSESSION_ID, BEGINNINGSESSION, SESSIONCONTINUE, ACCT_MULTI_SESSION_ID, DATAOCTETCOUNTORIGINATING, DATAOCTETCOUNTTERMINATING, ACCTSESSIONTIME)
    Values (2, '5C4CA98EAC4C', '190001FE', 0, 1, "100014E1A949316E", 42012, 505004, 213);
    Insert into AAA_CDR (ACCTTYPE, MSID, ACCOUNTSESSION_ID, BEGINNINGSESSION, SESSIONCONTINUE, ACCT_MULTI_SESSION_ID, DATAOCTETCOUNTORIGINATING, DATAOCTETCOUNTTERMINATING, ACCTSESSIONTIME)
    Values (1, '5C4CA98EAC4C', '19000200', 0, 0, '100014E1A949316E', 0, 0, 0);
    Insert into AAA_CDR (ACCTTYPE, MSID, ACCOUNTSESSION_ID, BEGINNINGSESSION, SESSIONCONTINUE, ACCT_MULTI_SESSION_ID, DATAOCTETCOUNTORIGINATING, DATAOCTETCOUNTTERMINATING, ACCTSESSIONTIME)
    Values (2, '5C4CA98EAC4C', 0, '19000200', 1, '100014E1A949316E', 50224, 144566, 729).
    Insert into AAA_CDR (ACCTTYPE, MSID, ACCOUNTSESSION_ID, BEGINNINGSESSION, SESSIONCONTINUE, ACCT_MULTI_SESSION_ID, DATAOCTETCOUNTORIGINATING, DATAOCTETCOUNTTERMINATING, ACCTSESSIONTIME)
    Values (1, '5C4CA98EAC4C', '19000201', 0, 0, '100014E1A949316E', 0, 0, 0);
    Insert into AAA_CDR (ACCTTYPE, MSID, ACCOUNTSESSION_ID, BEGINNINGSESSION, SESSIONCONTINUE, ACCT_MULTI_SESSION_ID, DATAOCTETCOUNTORIGINATING, DATAOCTETCOUNTTERMINATING, ACCTSESSIONTIME)
    Values (2, '5C4CA98EAC4C', 0, '19000201', 1, '100014E1A949316E', 62634, 378416, 392);
    Insert into AAA_CDR (ACCTTYPE, MSID, ACCOUNTSESSION_ID, BEGINNINGSESSION, SESSIONCONTINUE, ACCT_MULTI_SESSION_ID, DATAOCTETCOUNTORIGINATING, DATAOCTETCOUNTTERMINATING, ACCTSESSIONTIME)
    Values (1, '5C4CA98EAC4C', '19000202', 0, 0, '100014E1A949316E', 0, 0, 0);
    Insert into AAA_CDR (ACCTTYPE, MSID, ACCOUNTSESSION_ID, BEGINNINGSESSION, SESSIONCONTINUE, ACCT_MULTI_SESSION_ID, DATAOCTETCOUNTORIGINATING, DATAOCTETCOUNTTERMINATING, ACCTSESSIONTIME)
    Values (2, '5C4CA98EAC4C', '19000202', 0, 0, '100014E1A949316E', 1457286, 9141033, 7574);
    commit;

    I need to calculate the sum (dataeoctetcountoriginating) + sum (dataoctetcountterminating) for each session
    It is average, but the beginning of the session and the end of the session, as below,
    for each ACCT_MULTI_SESSION_ID and MSID
    the beginning of the session is when the accttype = 1 and beginningsession = 1
    and the end of the session is at this time the accttype = 2 and SESSIONCONTINUE = 0


    1. collect the first accounting start CDR generated an event online for a user.
    Collect CDR AcctType is 1 and beginning of Session is 1 according to MSID. In
    also, see the value of the Acct-Multi-Session-ID field in the CDR.
    2. collect all Accountants stop CDRs generated during this event the user online.
    Collect CDR AcctType is 2 according to MSID and Acct-Multi-Session-ID.
    If the value of Session continues on a CD - r accounting stop is 0, it indicates that this CDR
    is the last CDR of accounting judgment that is generated during the event of the user's offline.
    3. calculate the total volume of the user during this event online.
    Add the values of the data fields Byte Count (termination) and data values
    Fields byte (native) Count in the accounts collected stop CDRs together to get
    the total volume of this event the user online.

    How can I find each session, then calculate the sum of this session?
    any help please

    Published by: user11309581 on July 13, 2011 22:01

    Is that what you are looking for:

    select
       acct_multi_session_id,
       max(ACCTSESSIONTIME)-min(ACCTSESSIONTIME)
    from AAA_CDR
    group by acct_multi_session_id
    

    According to the DDL and DML you provided, this is the output I see:

    ACCT_MULTI_SESSION_ID,MAX(ACCTSESSIONTIME)-MIN(ACCTSESSIONTIME)
    100014E19E21F16C,         14152
    100014E19775F169,         70
    100014E1A949316E,         7574
    
  • To display the first and last date of one month

    I have the date format in 10 Mar 10.
    My requirement is when ever I select the date in the dashboard for all the month it should show results of all the months.
    I had the request for obiee101.blogspot.com.but if I use that sometimes it is not the latest results of the day. Any body please give me the query to display the results for the first day and lastday?
    I select any day from the drop-down menu of the guest, it must display the month of ex: if results
    If I select either 1 mar mar 10.2 10,30 mar 10...
    It should give results for the month of March.
    Can you please provide me the query for the last month also?
    If I select March date date print want to display the results of March together in a single column, results of the previous months in the other column

    Someone help me to achieve this?

    Yes, you are right. Jean SQL for the last day of the month, if the "last day of the previous month" ends on June 30, that "adding a month" will result in the 30th of the following month. But if the next month has 31 days, you don't miss this day here.

    Use it for the last day of the current month.

    TIMESTAMPADD (SQL_TSI_DAY-1, TIMESTAMPADD (SQL_TSI_MONTH, 1, TIMESTAMPADD (SQL_TSI_DAY, 1, TIMESTAMPADD (SQL_TSI_DAY, DAYOFMONTH (CURRENT_DATE) *-1, CURRENT_DATE))))

    The SQL above will ensure that you will get always the last day of the month "current" no matter how many days during the previous or current month.

  • Remove duplicates by selecting the first line of each subgroup in a Recordset

    Oracle: 11 GR 2

    Client Windows 7

    I have a set of data (the result of a query) which is similar to:

    D_rank product_id product_desc category income price cost

    1 112233 prod1-iphone phone 200 500 100

    1 112233 prod1-iphone4 phone 200 500 100

    2 223344 prod2-300 1000 400 windows7 OS

    2 223344 prod2-300 1000 400 software windows7

    3 334455 prod3-Mac 1000 computer 1500-1000

    4 445566 prod4-xyz 2000 800 1200 misc

    :                    :               :                                   :               :             :              :

    :                    :               :                                   :               :             :              :

    :                    :               :                                   :               :             :              :

    As you can see the first 4 rows, these rows are repeated due to the product_desc and category material. I need these fields but the first value in each subgroup, so that each row is unique. I.e.

    D_rank product_id product_desc category income price cost

    1 112233 prod1-iphone phone 200 500 100

    2 223344 prod2-300 1000 400 windows7 OS

    3 334455 prod3-Mac 1000 computer 1500-1000

    4 445566 prod4-xyz 2000 800 1200 misc

    :                    :               :                                   :               :             :              :

    :                    :               :                                   :               :             :              :

    :                    :               :                                   :               :             :              :

    You will enjoy the little help.

    Hello

    user13667036 wrote:

    Oracle: 11 GR 2

    Client Windows 7

    I have a set of data (the result of a query) which is similar to:

    D_rank product_id product_desc category income price cost

    1 112233 prod1-iphone phone 200 500 100

    1 112233 prod1-iphone4 phone 200 500 100

    2 223344 prod2-300 1000 400 windows7 OS

    2 223344 prod2-300 1000 400 software windows7

    3 334455 prod3-Mac 1000 computer 1500-1000

    4 445566 prod4-xyz 2000 800 1200 misc

    :                    :               :                                   :               :             :              :

    :                    :               :                                   :               :             :              :

    :                    :               :                                   :               :             :              :

    As you can see the first 4 rows, these rows are repeated due to the product_desc and category material. I have need of these fields but the first value of each subgroup...

    ...

    What does "first" here?  What "subgroup"?

    Depending on your needs, maybe you want to Request Top - N, something like this:

    WITH got_r_num AS

    (

    SELECT d_rank, product_id, product_desc, category, price, income, cost

    ROW_NUMBER () OVER (PARTITION BY d_rank

    ORDER BY product_desc, category

    ) AS r_num

    OF data_set

    )

    SELECT d_rank, product_id, product_desc, category, price, income, cost

    OF got_r_num

    WHERE r_num = 1

    ;

    I hope that answers your question.

    If this isn't the case, please post a small example of data (CREATE TABLE and INSERT statements) and the results desired from these data.  (I know you said this is a game of results from a query, and not an array, but the solution is the same as the entry is a single table, or a query, perhaps involvoing several tables.)

    Report when the request above is erroneous results and explain, using specific examples, how find you the correct results from these data.

    As said ground, see the FAQ in the forum: Re: 2. How can I ask a question on the forums?

  • How can I select the first date (at least) and the corresponding date of two different tables source?

    I have 2 tables, INVOICE and INVOICE_REFNUM similar to below. I'm writing a query that withdrawing the first date (less) for a single record remaining the two tables. Each table records the receipt of invoices, but according to the source of the received invoice some may reside in INVOICE_REFNUM and others the INVOICE table. I also use DECODE on the topic of INVOICE_SOURCE, when the date less is taken from the INVOICE table that contains that field, so if the date is in the field INVOICE_REFNUM DECODE is not necessary. Example:

    INVOICE (table)

    INVOICE_GID INVOICE_SOURCE INSERT_DATE

    ABC. AVRT123 I HAVE 11/03/2012-15:49:32

    ABC. CNWY234 G 12/03/2012 14:07:30

    ABC. UPGF678 M 15/03/2012 20:21:54

    INVOICE_REFNUM (table)

    INVOICE_GID INVOICE_REFNUM_QUAL INVOICE_REFNUM_VALUE INSERT_DATE

    ABC. AVRT123 SOURCE ACS 11/03/2012 14:49:32

    ABC. CNWY234 SOURCE CSA 12/03/2012 13:07:30

    ABC. UPGF678 SOURCE ACS 15/03/2012 21:21:54

    My decode statement is: DECODE ("INVOICE_SOURCE, 'I', 'IDE', 'G', ' Auto-Pay", ', 'Manual')

    If I were to write a query on these two tables, the output will resemble the following:

    INVOICE_GID INVOICE_SOURCE INSERT_DATE

    ABC. AVRT123 ACS 11/03/2012 14:49:32

    ABC. CNWY234 ACS 12/03/2012 13:07:30

    ABC. UPGF678 Manual 15/03/2012 20:21:54

    I worked on it for 2 days, and I was able to pull a date by using the following SQL code, but cannot determine how to extract the corresponding source:

    SELECT THE LEAST (GLOGOWNER. INVOICE_REFNUM. INSERT_DATE, GLOGOWNER. THE INVOICE. INSERT_DATE) AS 'DATE OF THE INVOICE.

    GLOGOWNER. THE INVOICE. INVOICE_GID,

    DECODE (GLOGOWNER. THE INVOICE. INVOICE_SOURCE, 'I', 'IDE', 'G', 'Auto-Pay', ', 'Manual').

    GLOGOWNER. INVOICE_REFNUM. INVOICE_REFNUM_VALUE

    OF GLOGOWNER. INVOICE

    LEFT JOIN GLOGOWNER. INVOICE_REFNUM

    ON GLOGOWNER. THE INVOICE. INVOICE_GID = GLOGOWNER. INVOICE_REFNUM. INVOICE_GID

    WHERE GLOGOWNER. INVOICE_REFNUM. INVOICE_REFNUM_VALUE = "ACS."

    AND GLOGOWNER. INVOICE_REFNUM. INVOICE_REFNUM_QUAL_GID = 'SOURCE '.

    AND GLOGOWNER. THE INVOICE. INVOICE_TYPE = 'I '.

    ORDER OF GLOGOWNER. THE INVOICE. INVOICE_GID

    Any help is greatly appreciated!

    Best regards

    -Adam

    Hello

    Is that what you want?

    SELECT i.invoice_gid

    CASE

    WHEN ir.insert_date<= i.insert_date ="" then ="">

    WHEN i.invoice_souce = 'I' and THEN 'EDI '.

    WHEN i.invoice_souce = 'G' THEN 'debit '.

    WHEN i.invoice_souce = am' THEN 'manual '.

    END AS invoice_source

    , The LEAST (i.insert_date, ir.insert_date) AS insert_date

    I have the Bill OF

    JOIN invoice_refnum ON i.invoice_gid = ir.invoice_gid ir

    WHERE ir.invoice_refnum_value = 'ACS '.

    AND ir.invoice_refnum_qual_gid = 'SOURCE '.

    AND i.invoice_type = 'I '.

    ORDER BY i.invoice_gid

    ;

    There is no reason to do an outer join if you only want the lines with specific values anyway.

    What happens if the 2 tables have exactly the same invoice_date?  The query above takes the invoice_source of invoice_refnum in this case, but that can easily be changed.

    Or the other of the insert_dates can be NULL?

    I hope that answers your question.

    Otherwise, thank you post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also after the results you want from these data (otherwise what you have already posted).

    Explain, using specific examples, how you get these results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002#9362002

  • Close the startpoint and endpoint without selecting the first

    Hi guys,.

    I'm working on an image of polygon which means I have created hundreds and hundreds of small triangles with the path tool.

    Now, I have wondered if it is possible to create two lines of the triangle in hand and close the last third line of triangles in shortcut.

    There may be a shortcut (or almost) to connect the beginning and the end of a path? I know I can do it by clicking on cmd + J, but I first select the points which is more work than simply connecting them to the hand. It would be perfect if there's any way to close it without selecting it first, so that I can do an 'action' out of it with a shortcut!

    Any ideas?

    Pathfinder unite.

Maybe you are looking for

  • How to change the default preset list of radio stations IP Journe air 1000

    I just bought a Journe air 1000.I bought this product in order to listen to radio IP in addition to visualize the sideshows. In the manual it says that there is no Mode for Radio IP (access to the SHOUTcast Protocol, with the default channels 30-50)

  • Games on Satellite A505-S6973

    Gods of colleagues toshiba, good night. I would like to know if it is possible to play games on my toshiba satellie A505-S6973. A colleague of mine has a dell studio xps and it can that disgusted me because if he can do it why not can I and we all kn

  • explain DAQmx WARNING 200035 conversion rates lower clock rate minimum?

    I'm sampling of data at 1 kHz on 3 channels using DAQmx read.  The DAQmx Read function returns a warning that: "Specified clock rate is lower than the minimum conversion rate of the ADC." Your data may be invalid. The material I have is a Multifuncti

  • a peripheral window and printer does not work

    Start - menu I select devices and printers - windows opens - but never get to the end to see my printers installed? Series g HP Pav ilion with win 7 is "new", all the available updates installed

  • Notification push (hub icon)

    Hello I'm able to generate the push using C2DM my opinion falls within the category of the notifications. Currently the notification, alarm icon display, I want to use my application icon instead of the icon of alarm on this subject. I see that Skype