Select a record for each Member of the Group

Hello
will have a table where in I'll take data for so many members of the group. I need to retrieve data for a particular group whose number of rows of data may be more in number (but I don't want only one row of data for each Member of the Group)

Here is the query to retrieve all rows of data
select RI.RESOURCE_NAME,TR.MSISDN,TR.ADDRESS1_GOOGLE, TR.MSG_DATE_INFO, FROM TRACKING_REPORT TR, RESOURCE_INFO RI 
WHERE TR.MSISDN IN (SELECT MSISDN FROM RESOURCE_INFO WHERE GROUP_ID ='1' AND COM_ID=2 ) AND RI.MSISDN=TR.MSISDN 
 order by MSG_DATE_INFO
This query result is...
>
DDD 12345 13 March 10 19:43:03
EEE 54321 Tamilnadu, India 13 March 10 19:39:48
DDD 12345 13 March 10 19:32:58
EEE 54321 Tamilnadu, India 13 March 10 19:30:07
DDD 12345 13 March 10 19:23:08
EEE 54321 Tamilnadu, India 13 March 10 19:20:14
FFF 98765 March 13 10 19:19:22
DDD 12345 13 March 10 19:13:01
EEE 54321 Tamilnadu, India 13 March 10 19:09:50
DDD 12345 13 March 10 19:02:56
EEE 54321 tn, ind March 13, 10 18:59:49
DDD 12345 13 March 10 18:53:08
EEE 54321 tn, ind March 13, 10 18:49:50
DDD 12345 13 March 10 18:42:56
EEE 54321 tn, ind March 13, 10 18:39:50
DDD 12345 13 March 10 18:33
EEE 54321 tn, ind March 13, 10 18:29:50
DDD 12345 13 March 10 18:22:54
EEE 54321 tn, ind March 13, 10 18:19:50
DDD 12345 13 March 10 18:12:56
EEE 54321 tn, ind March 13, 10 18:09:50
DDD 12345 13 March 10 18:02:54
EEE 54321 tn, ind March 13, 10 18:00:02
FFF 98765 Tamilnadu, India March 13, 10 17:59:26
FFF 98765 Tamilnadu, India March 13, 10 17:54:26
DDD 12345 13 March 10 17:52:56
EEE 54321 tn, ind March 13, 10 17:49:50
FFF 98765 Tamilnadu, India March 13, 10 17:49:25
FFF 98765 Tamilnadu, India March 13, 10 17:44:26
DDD 12345 13 March 10 17:42:56

>

This output, I only want a new album for each member(ddd,eee,fff). That is to say
>
DDD 12345 13 March 10 19:43:03
EEE 54321 Tamilnadu, India 13 March 10 19:39:48
FFF 98765 March 13 10 19:19:22
>

How to change the query to do this...?

Ok. I looked more carefully at your sample and it looks like you are looking for:

SELECT  RI.RESOURCE_NAME,
        TR.MSISDN,
        MAX(TR.ADDRESS1_GOOGLE) KEEP(DENSE_RANK LAST ORDER BY TR.MSG_DATE_INFO),
        MAX(TR.MSG_DATE_INFO)
  FROM  TRACKING_REPORT TR,
        RESOURCE_INFO RI
  WHERE TR.MSISDN IN (
                      SELECT  MSISDN
                        FROM  RESOURCE_INFO
                        WHERE GROUP_ID ='1'
                          AND COM_ID=2
                     )
    AND RI.MSISDN = TR.MSISDN
  GROUP BY  RI.RESOURCE_NAME,
            TR.MSISDN
/ 

SY.

Tags: Database

Similar Questions

  • SQL query to retrieve a single record for each employee of the following table?

    Hi all

    Help me on the writing of SQL query to retrieve a single record for each employee of the following table? preferably a standard SQL.

    CREATE TABLE xxc_contact)

    empnum NUMBER,

    alternatecontact VARCHAR2 (100),

    relationship VARCHAR2 (10),

    phtype VARCHAR2 (10),

    Phone NUMBER

    );

    insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Cell', 9999999999)

    insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Work', 8888888888)

    insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Work', 7777777777)

    insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Home', 3333333333)

    insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Cell', 9999999999)

    insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Home', 9999999999)

    expected result:

    EmpNum AlternateContact Relationship PhType Phone       

    123456 rick Grimes SP cell 9999999999

    Daryl Dixon EN work 7777777777 123457

    Home 123458 Maggie Greene CH 6666666666

    Thanks in advance.

    994122 wrote:

    Thank you all, that I got a result

    http://www.orafaq.com/Forum/m/620305/#msg_620305

    By Lalit Kumar B...

    Specifically, the two simple solutions provided were:

    1 using the row_number, entitled Oracle ranking based on descending order of the inside telephone each empnum group. And finally selects the lines which has least rank (of least since that order is descending for phone).

    SQL > column alternatecontact format A20;

    SQL >

    SQL > SELECT empnum, alternatecontact, relationship, phtype, phone

    2 from (SELECT a.*, row_number() over r (PARTITION BY empnum ORDER BY phone / / DESC))

    3 FROM xxc_contact one)

    4. WHEN r = 1

    /

    EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE

    ---------- -------------------- ---------- ---------- ----------

    123456 rick Grimes SP cell 9999999999

    Daryl Dixon EN work 7777777777 123457

    Home 123458 Maggie Greene CH 6666666666

    2. with the help of MAX, Oracle automatically assigns the maximum phone for all the rows in each group of empnum. And finally selects the rows with the maximum phone. Order by clause is omitted here intentionally. You can find out why.

    SQL > SELECT empnum, alternatecontact, relationship, phtype, phone

    2 (SELECT a.*, MAX (phone) over (PARTITION BY empnum) rn FROM xxc_contact one)

    3 WHERE phone = rn

    4.

    EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE

    ---------- -------------------- ---------- ---------- ----------

    123456 rick Grimes SP cell 9999999999

    Daryl Dixon EN work 7777777777 123457

    Home 123458 Maggie Greene CH 6666666666

    Kind regards

    Lalit

  • Ungroup a group and keep the scriptlabel for each item in the Group

    Hello

    does anyone know how to ungroup a group of rectangles with a certain tag (example groupA) give one every rectangle a clean label (the same text groupA)

    I can find the Group and ungroup it but I can't label the rectangles...

    var oPageItems = app.activeDocument.allPageItems;

    for (var j = oPageItems.length - 1;)  j > = 0; d-) {if (oPageItems [j] .label == ("groupA")) {oPageItems [j] .ungroup ()))}}

    ...???

    Help, please

    Hello

    front

    oPageItems [j] .ungroup ();

    go through the loop and set a label for each item within the Group:

    for (var k; k)< opageitems[j].length;="">

    oPageItems [j] [k] .label = "groupA";

    assuming that your oPageItems [j] is a group indeed.

    I hope that...

  • Are there separate libraries for each Member in the family plan?

    We want to start the Apple family of music Plan in our House, but everyone in my family wants to add their own music and to keep it separate from the rest of the members of the plan.

    I have 2 questions about it:

    1. every member gets their own library of music that they can sort and customize without interfering with the music of other members?

    2. each member individually has the limit of 100,000 of the song, or is it 100 000 songs for the whole family?

    We will get the plan until these issues are addressed, if anything like that would be useful!

    Hi Josie1374,

    I understand that you have a few questions about the sharing of family in Apple music. I have some information for you which should be able to help answer these questions. First of all, you should know that each family member in the family of the Apple music-sharing plan will be themselves, individual account, Apple's music:

    A subscription to Apple's music for
    each Member of your family.

    With a family membership of Apple's music, up to 6 people in your family can enjoy unlimited access to music from Apple on their devices. Everyone gets full access and individual music library of Apple, recommendations of experts, radio world-wide 24/7 with 1 beats and radio on demand. This is the world of music for the creations of any

    iCloud - family sharing - Apple

    https://www.Apple.com/icloud/family-sharing/

    As is the case, this information applies to each individual account, which should solve your second question:

    How music Apple manages your downloaded songs

    • You can have up to 100 000 songs in your music library. Songs you purchased from the iTunes Store do not count against this limit.

    Add music to your collection to your music library Apple - Apple Support

    https://support.Apple.com/en-us/HT204925

    Be vigilant and thank you for visiting the communities of Apple Support.

  • I need a query that selects the amount of records for each day of a table.

    I need a query that selects the amount of records for each day of a table.
    For example, the result would be:

    1 14 date
    Date 2-3

    etc.

    Any ideas?

    Sort:

    SELECT count ([IDCommentaire]), convert (varchar, dateAdded, 112)

    OF COMMENTSgroup by convert (varchar, dateAdded, 112)

  • For all the records for each record double, I need to get a single column with null or 0.

    Hi all

    I have a requirement where I need to get all the records, for each record in double, I need to get a single column with null or 0.

    create table a1

    (

    Identification number,

    VARCHAR2 (100), the point

    part varchar2 (100));

    Insert into a1

    values (1, 'ABC', 'A1');

    Insert into a1

    values (2, 'DEF', 'A2');

    TABLE A

    PART ITEM ID

    1 ABC A1

    1 ABC A1

    1 ABC A1

    DEF 2 A2

    DEF 2 A2

    3 DEF A2

    O/P

    PART ITEM ID

    1 ABC A1

    1        ABC             0

    1        ABC             0

    DEF 2 A2

    2       DEF              0

    3       DEF              0

    Thanks in advance.

    Thanks for your help FrankKalush...

    This one will work.

    WITH got_r_num AS

    (

    SELECT NVL (a1.id, a1.id) as id

    NVL (a1.item, a1.item) AS element

    NVL (a1.part, a1.part) IN the framework

    a1.id AS a_id

    ROW_NUMBER () OVER (PARTITION BY a1.id

    ORDER BY NULL

    ) AS r_num

    BY the a1

    )

    SELECT id

    element

    CASE

    WHEN a_id IS NOT NULL

    AND r_num = 1

    THEN part

    ELSE ' 0'

    END in the framework

    OF got_r_num

    ;

  • Select the last value for each day of the table

    Hello!

    I have a table that contains several measures for each day. I need two queries on this table, and I'm not sure how to write them.

    The table stores the rows (sample data)
    *DateCol1                 Value       Database*
    27.09.2009 12:00:00       100           DB1
    27.09.2009 20:00:00       150           DB1
    27.09.2009 12:00:00       1000          DB2
    27.09.2009 20:00:00       1100          DB2
    28.09.2009 12:00:00       200           DB1
    28.09.2009 20:00:00       220           DB1
    28.09.2009 12:00:00       1500          DB2
    28.09.2009 20:00:00       2000          DB2
    Explanation of the data in the sample table:
    We measure the size of the data files belonging to each database to one or more times a day. The value column indicates the size of the files of database for each database at some point (date in DateCol1 European model).


    What I need:
    Query 1:
    The query must return to the last action for each day and the database. Like this:
    *DateCol1       Value      Database*
    27.09.2009        150          DB1
    27.09.2009       1100          DB2
    28.09.2009        220          DB1
    28.09.2009       2000          DB2
    Query 2:
    The query should return the average measurement for each day and the database. Like this:
    *DateCol1       Value      Database*
    27.09.2009       125          DB1
    27.09.2009      1050          DB2
    28.09.2009       210          DB1
    28.09.2009      1750          DB2
    Could someone please help me to write these two queries?

    Please let me know if you need further information.

    Published by: user7066552 on September 29, 2009 10:17

    Published by: user7066552 on September 29, 2009 10:17

    Why two queries when it suffice ;)

    SQL> select dt
      2       , db
      3       , val
      4       , avg_val
      5    from (
      6  select dt
      7       , val
      8       , db
      9       , row_number () over (partition by db, trunc (dt)
     10                                 order by dt desc
     11                            ) rn
     12       , avg (val) over (partition by db, trunc (dt)) avg_val
     13    from test)
     14   where rn = 1
     15  order by dt
     16  /
    
    DT        DB           VAL    AVG_VAL
    --------- ----- ---------- ----------
    27-SEP-09 DB2         1100       1050
    27-SEP-09 DB1          150        125
    28-SEP-09 DB2         2000       1750
    28-SEP-09 DB1          220        210
    
  • How can I make a cell formula will apply for the entire column? For example D2 appears B2 - C2. How can I copy this formula for each cell in the column?

    How can I make a cell formula will apply for the entire column? For example D2 appears B2 - C2. How can I copy this formula for each cell in the column?

    If you want the formula is the same (B2 - C2) in the cell of each column you must change it as ($B$ - 2$ C$ 2). Then copy it, select the whole column and paste.

  • Where is 'Create a separate record for each volume' past? in VMware-converter - 4.0.1 - 161434.

    Where is 'Create a separate record for each volume' past? in VMware-converter - 4.0.1 - 161434 (independent). Option is not more than 4 converter?

    Hello.

    When you get to the third tab called "View/Edit Options", choose the Edit option for 'Data to copy.'  Then choose the option advanced at the end of the menu "data copy type" and then use the options on the page layout tab target to assign separate discs.

    Good luck!

  • Creation of 5 rows in table B for each row in the table has

    create table A
    (col1 number,
    col2 varchar2(20)
    )
    /
     
    create table B
    (col1 number,
    col2 varchar2(20)
    )
    /
    
    insert into A values (1,'Jane');
    insert into A values (2,'Kate');
    insert into A values (3,'Stomp');
    
    
    SQL> select * from a;
    
          COL1 COL2
    ---------- -----------------
             1 Jane
             2 Kate
             3 Stomp
    For each row in the table, I want 5 rows to be created in the table b. table B should look like
        COL1   COL2
    ---------- -----------------
             1 Jane
             2 Jane
             3 Jane
             4 Jane
             5 Jane
             6 Kate
             7 Kate
             8 Kate
             9 Kate
             10 Kate
             11 Stomp
             12 Stomp
             13 Stomp
             14 Stomp
             15 Stomp
    How can I do this?

    Hello

    A way

    insert into b
    select rownum*5  , col2 from a
    union all
    select rownum*5+1, col2 from a
    union all
    select rownum*5+2, col2 from a
    union all
    select rownum*5+3, col2 from a
    union all
    select rownum*5+4, col2 from a
    

    Concerning
    Anurag

  • Type a table defined clusters to hold configuration data - definition of default values for each element of the array

    Hello

    I was wondering if I could get some information and opinions on the use of an array of type defined clusters to store configuration data.  I am creating a program to test several EHR and wanted to have a control of type defined for each HAD with the information needed to create the DAQmx tasks for all signals for it must HAVE.  I am eager to do so that the data are encoded in hard and not in a file that the user might spoil.

    Controls of type def are then put into a Subvi who chooses as appropriate, one based on the enumeration of Type DUT connected to a case structure.

    I have problems with the control of the defined type.  I see issues when you try to save a configuration unique to each element of the array in the array of clusters.  Somehow, it worked at first, but now by clicking on "Operations on the data--> default font of the current value ' on individual elements of the cluster or the entire cluster (array element) does not save data when I re - open the command def.  What I am doing wrong?  I'm trying to do something with the berries of the clusters that I shouldn't do?

    I enclose one of the defined reference type controls.  I tried to change it bare to see if that helped, but no luck.

    To reproduce, change the resource string for the element 0 of the array and do the new value by default.  Then close the def of type, and then reopen it.  The old value is always present in this element.  The VI is saved in LabVIEW 2012.

    The values of a typedef are not proprigated to the instances of the control. They get if created WHEN data values have changed. They will be not updated with the changes to come. You must create a VI specifically to hardcode your values or to implement a file based initialization. The base file would be much better and more flexible. If you don't want users to change the data simply encryption. There is a wedding blowfish library that you can download.

  • Error in Event Viewer: loading libraries of dynamic links customized for each application. The system administrator should review the list of libraries

    My system features, i7 thinkpad w540, 16 GB of ram and a 256 GB ssd. Using MSE as av with AMBM pro

    whenever I start my system, win 7 x 64, I get the following error in the event viewer:

    Custom dynamic link libraries are loaded for each application. The system administrator should review the list of libraries to ensure that they are linked to trusted applications.

    any help with this error?

    Atul

    Description: NVIDIA shim dll initialization

    Product: Shim NVIDIA D3D drivers
    Company: NVIDIA Corporationhttp://systemexplorer.net/file-database/file/nvinit-dll/33069751

    I would not be concerned by this driver.

  • call a stored procedure for each row in the transitional attribute and display the data in the form of af: table. The other rows are based on the entities

    Hi Experts,

    JDeveloper 12.1.3.0.0

    I have a VO based on entity object. With a column of the VO is transient attribute (I created).

    I need to call a stored procedure for each row in the transitional attribute and display the data in the form of af: table. As well as other attributes.

    So can anyone suggest how can I achieve this?

    Thank you

    AR

    I think that you need a stored function (which returns the value) in this case, is not?

    Take a look at:

    https://docs.Oracle.com/CD/B31017_01/Web.1013/b25947/bcadvgen005.htm

    and search for:

    Invoking stored function with only Arguments in

    call your function in the Get attribute and return value accessor...

  • The opportunity to identify a specific storage for each user or security group.

    Hi all

    I asked how to specify storage for each user or security group on the server of the University Complutense of Madrid. ex. I want user 'weblogic' unable to download a document on the server of the University Complutense of Madrid, more than a gigabyte. the user can check in several files, but thetotal space for all files are not a gigabyte.

    Thank you

    I asked how to specify storage for each user or security group on the server of the University Complutense of Madrid. ex. I want user 'weblogic' unable to download a document on the server of the University Complutense of Madrid, more than a gigabyte. the user can check in several files and the total space for all files not exceeding a gigabyte.

    You can write a rule to achieve this where in the xStorageRule is evaluated based on any set of metadata such as dDocAuthor or dDocSecurityGroup etc., or a combination of metadata.

  • Hierarchy with each Member of the child's repeated occurrences

    I created a simple hierarchy in OBIEE Administration tool, as follows:

    Hierarchy.JPG

    When I create an analysis using this hierarchy, I would expect the following:

    Expected.jpg

    Instead, I'm multiple occurrences of each Member of the child, as follows. I do not know what is causing the failure, because none of these criteria, I have included in the analysis.

    Actual.jpg

    Take a look at the generated query physical if you are 100% sure of what groupping done OBIEE and from there you can find on the issue.

    You can also start by dual control key you defined (Sun and hierarchy) and, of course, that I'm sure you didn't play too much with content levels to set some strange things, but they are well positioned to match your hierarchies, right?

Maybe you are looking for

  • My iCloud photo storage is half of my library.  Why?

    My iCloud photo storage is half of my library (on my MacMini).  Why?

  • Thickness of the plot

    Hi all I am doing a project in LabWindows/CVI, where I have to post 16 tracks. I did it with a StripChart, but I had to reboot with graphic, because I wanted to use the zoom feature. Now, I can show my 16 tracks on the chart, but I have a problem wit

  • Geniune windows xp professional download

    Hello I have microsoft windows xp professional service pack 3 installed on my pc (and of course it is geniune) and I installed updates to update.microsoft.com, but for some reason, I need the installation package for my Os (xp - sp2 or xp - sp3) to r

  • ERROR 1606 - OpenOffice

    I just download OpenOffice 3.3 from their download site. When I tried opening the exe file. file, I received an error message: "Error 1606 could access the network OpenOffice.org 3 location . I have Windows Vista Basic and have never had problems dow

  • Windows Live Messenger is not responding

    Hello I had problems with Windows Live Messenger anywhere, I log on. I registered my desktop computer, a Windows Vista operating system and when I start discussing it stops responding. When I went to sign on my Windows Messenger for Mac, I have exper