Count of partners who appeared with the other

Hello

I have a table t
create table T
(player varchar2(40),
for_team varchar2(10),
Vs_team varchar2(10),
matchid number,
points number)
/


INSERT INTO T VALUES ('John','A','B',1,2);
INSERT INTO T VALUES ('Fulton','A','B',1,10);
INSERT INTO T VALUES ('Sarah','A','B',1,9);
INSERT INTO T VALUES ('Peter','B','A',1,7);
INSERT INTO T VALUES ('Carlos','B','A',1,9);
INSERT INTO T VALUES ('Jose','B','A',1,6);
INSERT INTO T VALUES ('Joe','A','B',2,8);
INSERT INTO T VALUES ('Peter','A','B',2,9);
INSERT INTO T VALUES ('Carlos','A','B',2,1);
INSERT INTO T VALUES ('Rubben','B','A',2,10);
INSERT INTO T VALUES ('John','B','A',2,0);
INSERT INTO T VALUES ('Fulton','B','A',2,1);
INSERT INTO T VALUES ('Marcelo','A','B',3,7);
INSERT INTO T VALUES ('Daniela','A','B',3,1);
INSERT INTO T VALUES ('John','A','B',3,2);
INSERT INTO T VALUES ('Jose','B','A',3,5);
INSERT INTO T VALUES ('Abrao','B','A',3,3);
INSERT INTO T VALUES ('Carlos','B','A',3,10);


Select * from t
order by matchid, for_team
/

Player For_team vs_team  matchid   Points
John       A       B       1       2
Fulton     A       B       1       10
Sarah      A       B       1       9
Carlos     B       A       1       9
Peter      B       A       1       7
Jose       B       A       1       6
Peter      A       B       2       9
Carlos     A       B       2       1
Joe        A       B       2       8
Fulton     B       A       2       1
John       B       A       2       0
Rubben     B       A       2       10
Daniela    A       B       3       1
John       A       B       3       2
Marcelo    A       B       3       7
Jose       B       A       3       5
Abrao      B       A       3       3
Carlos     B       A       3       10
Note: Each player may appear more teams in different matches. For example, John appeared for team one matchid = 1 and then matchid = 2, he appeared for the B team. So even could for other players

Requirment:
I want the sum of the number of matches and points for each player (which is easy using the SUM), but with a number total of different teammates he played with all the matches, that it appeared [teams] and also opposition players number total and finally the total number of different actors, in which he played with in all matches as it appeared.

Just to clarify some terms, incase any doubt:

Teammates CIHI = all players who have appeared (for_team) in a game for the same team for which the player also appeared in the same game.
opposition players = all players who have appeared for VS_team played by each player.
total of the various actors = all the unique players who appeared for for_team or vs_team in games in which each player appeared.
Here is my desired outout:

Player    total Matches    Sum(points)   Different teammates    Different opposition players    total different players
                                         player played with     player played with              player played with
John      3                4             5                      5                               10
Fulton    2                11            3                      4                               6  
Sarah     1                9             2                      3                               5
Peter     2                16            3                      4                               7
Carlos    3                20            4                      6                               10
Jose      2                11            3                      5                               8
Joe       1                8             2                      3                               5
Rubben    1                10            2                      3                               5
Marcelo   1                7             2                      3                               5
Daniela   1                1             2                      3                               5
Abrao     1                3             2                      3                               5       
I want a simple query and query shorter to reach production, since in my data table are enormous.

Thanks in advance.

concerning
Ramis
with teammates as (
                   select  t1.player,
                           t2.player teammate
                     from  t t1,
                           t t2
                     where t2.matchid = t1.matchid
                       and t2.for_team = t1.for_team
                       and t2.player != t1.player
                  ),
     opponents as (
                   select  t1.player,
                           t2.player opponent
                     from  t t1,
                           t t2
                     where t2.matchid = t1.matchid
                       and t2.vs_team = t1.for_team
                  )
select  distinct player "Player",
                 count(distinct matchid) over(partition by player) "total Matches",
                 sum(points) over(partition by player) "Sum(points)",
                 (
                  select  count(distinct teammate)
                    from  teammates
                    where teammates.player = t.player
                 ) "Different teammates",
                 (
                  select  count(distinct opponent)
                    from  opponents
                    where opponents.player = t.player
                 ) "Different opponents",
                 (
                  select  count(distinct teammate)
                    from  (
                            select  *
                              from  teammates
                           union all
                            select  *
                              from  opponents
                          ) x
                    where x.player = t.player
                 ) "total different players"
  from  t
/

Player     total Matches Sum(points) Different teammates Different opponents total different players
---------- ------------- ----------- ------------------- ------------------- -----------------------
Sarah                  1           9                   2                   3                       5
John                   3           4                   5                   5                      10
Carlos                 3          20                   4                   6                      10
Joe                    1           8                   2                   3                       5
Jose                   2          11                   3                   5                       8
Abrao                  1           3                   2                   3                       5
Fulton                 2          11                   3                   4                       7
Peter                  2          16                   3                   4                       7
Rubben                 1          10                   2                   3                       5
Marcelo                1           7                   2                   3                       5
Daniela                1           1                   2                   3                       5

11 rows selected.

SQL> 

SY.

Tags: Database

Similar Questions

  • Acrobat-Pro XI does not appear with the other icons when I try to download

    I installed the applications Manager, but does not Acrobat Pro XI with other icons in the window when I try to download on my pc

    Hi Steven,

    the reason for not showing the Acrobat pro XI icon and other software on the small window of the adobe application manager is that the requirements is not met, only those programs that are compatible on your machine appears in the adobe Application Manager. You can check the technical specifications for software particaular on www.adobe.com. Hoe it will be useful.

    Thanks and greetings

    Copper Singh

  • I installed the 12 elements, it does not open, a screen will appear with the options e-12 and 4 other languages

    I installed the 12 elements, it does not open, a screen will appear with the options e-12 and 4 other languages.  When I click on 12 items, a screen will appear with a red install icon, I click and it askes for the serial number. It won't let me type in letters digits only. Already, I have the serial number once. How to make this work? I don't want to be a programmer!

    attach a screenshot of what appears after clicking PES 12, http://forums.adobe.com/thread/963429

  • KB955759 does not appear when I check the updates manually, but it appears with the yellow shield after you have enabled the automatic updates.

    original title: Windows Update acts confused - kb955759 does not appear when I check the updates manually, but it appears with the yellow shield after you have enabled the automatic updates.

    I just reset my CMOS settings, writing zeros for my hard drive, repartitioned, reformatted and used the recovery cd Gateway system to get my computer to Windows 98se - factory settings, except at the beginning of the recovery of the system, when it says "press any key for advanced options," I pressed a key and then I unchecked all the default (3rd party) applications including Norton and left only 2 checked: "Updated USB Hub" and "Windows Shutdown Supplement," while nothing has been installed, leaving only win98.
     
    Then I used my disc XP Home (SP2) update.  I, immediately after the upgrade to Windows XP, installed "Office XP with Frontpage, Developer Edition", then Norton 2012 before never connect to the internet.
    Then, I connected to the internet and continuously update of Norton, before ever hitting the Windows Update page. The first thing I did then was to activate Windows, and then activate the office.
    Then I hit the update of Windows "button" that says "get all your updates in one place... upgraded"Microsoft Update".  I, then, just kept hitting the page update and restart, until I find the SP3.  Then, I took a break, until the next day.
     
    I have an ADSL broadband, with a Linksys EtherFast PCI card.
     
    Then I got SP3, which installed without any problems.
    So I just kept "microsoft continuous update" manually (and reboot), until there is no more updates - EXCEPT, I always uncheck Windows Malicious Software Removal Tool - which was the only screening at the final stop for the night.  I think that I ticked the box "don't ask me about this update".
     
    Then, in the morning, after you have enabled automatic updates, I noticed the yellow shield - Windows security icon (or whatever it's called), so I clicked on it and checked it was tellimg me was available [when I checked "Custom Install (advanced users)"].  What showed was 1 update - 955759 KB.
     
    After the problem, already at the reformat (months and months), see the yellow shield telling me there are updates available, which were already installed (before rebooting), I checked manually on the internet with IE 8, pressing alt, "T", "U".  There is no updated list.  Then I checked through my history of update (twice), and KB955759 had not been installed.
     
    My update setting is to let windows download ('important') updates, but let me choose when to install them.
     
     
     
    What is the right - Windows Update (NO update important reporting) Site, or the yellow shield (reports [a] kb955759 [update])?
     
    I can not yet confirm he is supposed to be an update for XP home kb955759, because I was unable to locate any detailed documentation on this 'thing' that protect the yellow safety seems to think is a significant update.

    Comment 1: To my rquest, a moderator merged your thread in the Sub-forum Win7 updates with your wire in the Sub-forum of updates of Windows XP 20 Feb-12, c. 07:50 UTC.

    Comment 2: If you will not contact the MS Support on this issue?

    ~~~~~~~~~~~~~~~~~~~~~~~~~~

    Just for the heck of it, I have disabled the automatic updates, cleared my browser cache, checked manually, updates from microsoft (windows) and found none (with the exception of software malware removal tool windows [which I have not installed]).  Then, I turned the automatic updates on, and without even being connected to the internet, the yellow shield popped up with the kb955759 "update"...

    Repost...

    1. If you open Internet Explore (only!) to http://windowsupdate.microsoft.com and run a CUSTOM scan, KB955759 appears in results?... If so, you manage to install it and/or security updates available?

    2 after no. 1 above [<>], is the 'yellow shield' icon appears in the Notification area (on the left of your clock)?  .. and if yes, by clicking on the 'yellow shield' icon tells you that KB955759 or any other updates is ready-to-be-installed?  .. .and if so, you manage to install it?

    3 after doing 1 # & #2 above [<>], is KB955759 or any other updates offered as a ready-to-install update when you go off your computer?  .. .and if so, you manage to install it?

    ... I guess that clearing the browser cache does not erase 'downloaded' updates.

    Nope. If you want to clear the queue of the update...

    OPTION A:

    1. stop the automatic updates service:

    Start > run > (type or copy/paste) services.msc > click OK
    Double-click automatic updates > click stop
    (Stopping the service will take a moment)

    2 remove the contents of the download folder:

    Start > run > (type or copy/paste) %windir%\SoftwareDistribution > click OK

    Open the download folder and delete its content
    Close the window.

    3. start the automatic updates service:

    Start > run > (type or copy/paste) services.msc > click OK
    Double-click automatic updates > click Start
    (Starting the service will take a moment)

    OPTION B:

    1. open Internet Explorer (only!) to http://support.microsoft.com/kb/910336 [don't know the titles, etc..]

    2. make disappear/close the Troubleshooter automatically pop up.

    3 repaired 50202 in DEFAULT modes and AGGRESSIVE. [1]

    4 reboot.

    Does anyone know how to determine if software mailicious removal tool is installed on XP? [source ]

    Check the located log file...

    C:\Windows\Debug\ MRT. NEWSPAPER <>

    Related...

    ... This leaves us with the malicious software removal tool don't appear not.

    I guess I'll have to leave "auto-update" (I often have less than 65 M of free memory left and do not have enough memory to msrt) and don't assume no other current error. [source; 17 Aug-11]

    It's no wonder that you ended up having to do a clean install of Win98SE & then upgrade to Windows XP again!

    ================================================================
    [1] full Disclosure: the difficulty operating in AGGRESSIVE mode will remove your update history but not updates installed in Add/Remove Programs list.

  • I am trying to install Windows XP and during the process, a message appears with the title "RUNDLL__Error in iesetup.dll Missing entry: IEAccessSysInst. The process then stops and I cannot make progress.

    I am trying to install Windows XP and during the process, a message appears with the title 'RUNDLL '.
    "Error in iesetup.dll Missing entry: IEAccessSysInst.  The process then stops and I cannot make progress.

    Do not install an operating system is usually caused by (in order of probability):

    1. you are trying to install with other devices connected to the computer. Unplug them before trying to make an installation.

    2. "" "" defective installation media. "" Check the CD/DVD installation for scratches, tasks. Try another machine.

    3. bad optical drive. Test with another CD/DVD bootable or Exchange for a well-known work.

    4. faulty RAM. Test with Memtest86 + www.memtest.org . You will download the .iso image file to create a bootable cd. Burn the file with the third party burning software *-as an image, not in the form of data. Then start with the media that you did (you may need to change the boot priority in your BIOS so that the optical drive is the first boot device). The test runs immediately. The test run for an hour or two--at least that errors are seen immediately. If you get any errors, replace the RAM.

    * It is not necessary to have a third party burning software in Windows 7 since Win7 natively allows to burn an .iso. Other operating systems require it. A good free choice ImgBurn comes from www.imgburn.com .

    5. bad hard drive. Test with a diagnostic utility downloaded from site of the disc mftr... You create a bootable CD with the files you download. Burn the file with the third party burning software *-as an image, not in the form of data. Boot with the CD that you have done and do a full test of the reader. The physical tests fail, replace it.

    * It is not necessary to have a third party burning software in Windows 7 since Win7 natively allows to burn an .iso. Other operating systems require it. A good free choice ImgBurn comes from www.imgburn.com .

    6. other hardware components are faulty. MS - MVP - Elephant Boy computers - don't panic!

  • Are you aware of a possible bug in the version 3.6.23? In the browser, for example, "two /" appears with the slash through the 'o'. Is this a known bug? Thank you

    Are you aware of a possible bug in the version 3.6.23? In the browser, for example, "two /" appears with the slash through the 'o'. Is this a known bug?

    When the same text is seen in another browser, it is displayed correctly as "two."

    The same question is displayed on another computer.

    Thank you.

    Sounds that you use a font that supports ligatures (Palatino?).

  • Pencil of Apple works with the other iPads, or iPad pro?

    Pencil DDoes Apple works with the other iPads, or iPad pro?

    It works with the Pro

  • all my data is all save on the local disk c, how to share the data with the other drive, local drive d.

    all my data records on the local disk c, how to share the data with the other drive, local drive d.

    Hi Jasonbichard,

    1. what type of drive is D? Is - this another partition on the same disk?

    2 Windows operating system you are using?

    You can change the location of the disk to save the data in the d: instead of C: and check if it helps.

    a. navigate to the location (username) C:\Users\.
    b. right click on the folder that you want to change the location, and then select Properties.
    c. click on the location tab and change the location to D: drive.

    d. click on apply and Ok.

  • Anyone who works with the CAF (Caltech intermediate Format) files in LabVIEW?

    Hey everybody,

    Anyone who works with the CAF (Caltech intermediate Format) files? These are files that are generated by IC layout programs, such as TannerEDA L-Edit, that define the layers and arrangement of the masks used in VLSI (Photolithography) of processing semiconductor device.

    I would like to analyse these CIF files to generate a map of wafer of devices for use in the-plate test. Currently, a plan of shooting is made and then I manually switch and define coordinates of line and column for the edge of a plate and various places of drop-in. I would like to automate this process, and I don't know if it is possible by playback of these files from the CAF. However, I don't really know how to read them, and I can get as much information from the Wikipedia page and the original article.

    So I ask: anyone has an easier set of screws that make reading CIF file? Or someone working with them can help me with my problem? I can describe it in much better detail once someone comes...

    Here is one of my notebooks CIF of Mathematica (remove the .txt extension obviously).  I used it to create a new CIF file with four instances of the object in a file.

    You can load a file with the following text:

    symName = loadCIF;

    You can see the layers:

    CIFlayers [symName]

    You can view layers:

    Show [{viewCIFlayer [symName, #, color of layer]}]

    (if you wish, add multiple layers to the list)

    If you have a file of type CIF I can also test to see that it recognizes the objects you use, I am generally to polygons and boxes.

  • How can I share 'My images' with the other user accounts on my computer?

    How can I share 'My images' with the other user accounts on my computer?

    where are the 'experts' on these forums adverstised?  I can't get an answer to a simple question.  Does anyone know how to do this?

    Here we are, ok, I'm not an expert, but try this:

    Right click on 'My images' > share > specific people... > select that you want to share this folder with.

    ...

    After that, try to connect by using a different account. If you will not be able to open C:\Users\"FirstUser"\Pictures, you try to extend the network in the left pane of Windows Explorer > expand ComputerName > expand users > expand "FirstUser" > photos

  • whenever I start my windows, the dialog box appears with the words "persistence module a work stoppage" how to fix this problem?

    whenever I start my windows, the dialog box appears with the words "persistence module a work stoppage" how to fix this problem? someone help me please tell how to fix

    Hello

    1. have there been recent changes to the computer before the show?

    I suggest you to try the steps below and check if it helps.

    Method 1: Start your system in safe mode and check if the same problem occurs.

    http://Windows.Microsoft.com/en-us/Windows7/start-your-computer-in-safe-mode

    Method 2: If the question does not exist in Mode safe mode then try to put your computer in a clean boot state.

    By setting your boot system minimum state helps determine if third-party applications or startup items are causing the problem.

    How to troubleshoot a problem by performing a clean boot in Windows Vista or Windows 7:
    http://support.Microsoft.com/kb/929135

    Note: After the boot minimum troubleshooting step, follow step 7 in the link provided to return the computer to a Normal startup mode.

    Hope this information is useful.

  • HP Office Jet 5610 all in one does not appear with the fax

    I got a new computer with Windows 7 when I added my printer HP Office Jet 5610 all in one, it does not appear with the fax.  When I tried to install it with the disc from the printer, he Wouln't install.  What is the problem? I really need on the part of the printer fax.

    Hello

    Try this maybe this will help.

    -Type fax in the research - type on Windows and scan-new fax fax...

  • Why when I click with the left button of the mouse on the unique tool, you open the window with the other instruments?

    When I click with the left button of the mouse on the unique tool, open the window with the other instruments


    Mohito Hi, this morning, I solved the problem by trying to support. I realized that the problem was in mice, because the click rate is at its highest level, and then click the instruments was like if he did 2. I will now set the minimum speed of the clicks.

    Thank you

  • my up to date iMac can't read installing lightroom 5 dvd I received for Christmas, the dvd player works fine with the other dvd, is it possible to download the program with the serial number of the dvd?

    my up to date iMac can't read installing lightroom 5 dvd I received for Christmas, the dvd player works fine with the other dvd, is it possible to download the program with the serial number of the dvd?

    No need to worry about the disk version. He would just install an update anyway once it has been installed. Download from the link provided below and use the serial number, you need to activate.

    Updates

  • WebHelp TOC does not appear with the IE9 browser

    This is similar to the display is not in Chrome which I fixed. I use Robohelp 7 WebHelp TOC now does not appear with the IE9 browser.

    See you soon

    He solved.

    In whver.js

    Change of line 64} else if (gbIE4)

    TO

    } else if (gbIE55)

Maybe you are looking for

  • HP Pavilion 500-424: Mother Board, PSU, CPU Upgrade

    Hello I was wondering if I can upgrade the motherboard and the PSU and CPU Here is the link for the plug of the pc http://support.hp.com/us-en/document/c04453602 and if you can him so connect the motherboard and PSU suggested if I can improve

  • behavior strange safari

    Yesterday, I posted a discussion where it was trashed safari on my system.  Whenever I called safari, I got a message saying "ios crash warning."  Safari did not work.  I was able to access the sites that I should happen to use chrome. My wife enter

  • Film making

    I was told that Director is not supported by Windows 10, so what software should I use. Want something easy to patch set of small video clips from my camcorder and burn them on dvd. Anyone has any experience with FEATURES and I could use Videolan so

  • Back button with a focus for 5 d Mark III. How do I put in place?

    How can I configure button back focusing on my new 5 d Mark III.  Can not find the instructions manual supplied Canon or third book.

  • How to upgrade a dialog box text fields?

    Hi, I wanted to create a dialogue with a timer - I want one of the buttons to display OK (5) OK (4) OK (3) over time along. Is it possible to set the labels of the buttons in a dialog box, after it has been created? If this is not the case, what woul