using the... multiple loop and insert

Hello

I have the following structure:
create table schoolboys(
id integer,
name varchar2(20)
);

create table marks(
id integer,
mark number(2,0),
schoolboy_id integer
constraint fk_marks foreign key(schoolboy_id) references schoolboys(id)
);

create table avg_marks (
id integer
     constraint pk_avgmarks primary key(id)
schoolboy_id,
avg_mark number(4,2)
);

insert into schoolboys values (1, 'John');
insert into schoolboys values (2, 'Mary');

insert into marks values (1, 10, 1);
insert into marks values (2, 9, 1);
insert into marks values (3, 9, 1);
insert into marks values (4, 10, 1);
insert into marks values (5, 9, 1);
insert into marks values (6, 10, 2);
insert into marks values (7, 10, 2);
insert into marks values (8, 9, 2);
I want to calculate (using a loop for (I think) the average marks of each student, then I want to insert the results of the third table... for example, after having calculated the brand. moy, the third table must contain:
1 1 9.4
1 2 9,66

Help me please if you can

Kind regards

Edited by: Roger22 the 16.06.2009 09:49
API> INSERT INTO avg_marks
  2  SELECT ROWNUM, SEL.schoolboy_id, SEL.media
  3  FROM
  4    (SELECT schoolboy_id, AVG(mark) AS media
  5    FROM marks
  6    GROUP BY schoolboy_id) SEL;

2 filas creadas.

API> SELECT *
  2  FROM avg_marks;

        ID SCHOOLBOY_ID   AVG_MARK
---------- ------------ ----------
         1            1        9,4
         2            2       9,67

Tags: Database

Similar Questions

  • Any ideas how can I insert a pdf into word, by using the option object to insert. However, the pdf file that I want to insert text and annotated lines, but once inserted comments do not appear?  any help would be greatly appreciated.

    Any ideas how can I insert a pdf into word, by using the option object to insert. However, the pdf file that I want to insert text and annotated lines, but once inserted comments do not appear?  any help would be greatly appreciated.

    You will need to find a forum for MS Word, since it is the software you are trying to manipulate in the present.  If you think that the treatment/creation of the PDF file plays a role, then you should ask in the forum for the software that you use to create the PDF file.

    This forum is for a question about downloading and installing Adobe products test, so in all circumstances, your question does not fit in this forum.

  • I use the MODBUS library and can receive data, but I can send it very well?

    Hello

    I use the Modbus Library to communicate with a VFD to control a fan. I use the master write and read vi. I can write data to the drive mechanism and get the fan to do what I want. The VFD is supposed to send a package of confirmation after I told him to do something and I can also read its records. When debugging the VI it shows that the problem is that the buffer always reads zero and the VI timesout. If I look at the USB adapter lights to RS 485, I use to interface with the drive mechanism, I see that the flashes of light RX immediately after I send a message. So I should have something in the buffer. Does anyone have any suggestions?

    Aaron

    OK, here's what has happened to those who have this problem. In the series Receive.vi MB The bytes to the Port of property node has been reading 0 even if there was something in the buffer. Executing the program was then stuck in a loop until it expired and never went to read anything of serial port buffer. I didn't spend too much time wondering why that VI has not worked and created my own. Within a period appropriate after writing to the serial port, I used the same bytes to the Port property node and was able to get the exact number of bytes to the stream and then VISA vi the number of bytes to read. I received the message of the right answer and everything seemed good. But of course that NO! Then I experimented with different speeds of writing to the drive mechanism to get the fan to operate at different speeds. I found a small range of speeds where I get no response to the VFD, either in operation or by sending me a response packet. After a while, I found that there is a mistake in the LRC-8 code in the MODBUS library OR. It does not prescribe that the LRC will be a two-character value. So if your LRC is proving to be a single character such as F value (which should be 0F) you get an incomplete MODBUS message. This has been easily corrected in the vi LRC8 saying "number in hexadecimal string" vi to produce output with a minimum width of two. Then everything worked fine. Moral of the story, it's the MODBUS library is awkward.

  • I'm trying to connect two monitors and one using the hdmi port and the other vga. How can I get the pc to recognize the two?

    Original title: multiple monitors

    I'm trying to connect two monitors and one using the hdmi port and the other vga. How can I get the pc to recognize the two?

    Hi David,

    Thanks for posting your query on the Microsoft Community.

    I suggest you refer to the Microsoft Help Articles below and try the steps mentioned.

    Check out the link:

    http://Windows.Microsoft.com/en-in/Windows-8/how-connect-multiple-monitors#1TC=T1

    You can also check:

    http://Windows.Microsoft.com/en-in/Windows-8/get-best-display-monitor

    Hope this information helps. Please let us know if you need any other help with Windows in the future. We will be happy to help you.

  • How do I use the letters A and O in Dreamweaver?

    I wonder if there is any way I can use the letters A and o Dreamweaver transforms the letters some random mess. They are used in my mother tongue and so far I have not been able to use. I can't also set with change the language of Dreamweaver on my own since it was translated to it. Are they fixed if I download my files on the net? If this is not the case, what I have to do to fix this?

    Yes, you can use the accented characters in Dreamweaver, as long as you use a fairly recent version of Dreamweaver. Make sure that the document encoding is set to UTF - 8. If you can type accented directly from your keyboard characters, Dreamweaver inserts the characters directly.

    What you describe as back "some random mess" at the time where the browsers are not able to handle accented characters. Ä is the character entity HTML a. Older versions of Dreamweaver by default to Western European (iso-8859-1 encoding), which translates accented characters in the process of conversion to HTML character entities.

  • How to use the Group feature in insert or update

    Hai All

    How to use the Group feature in insert or update statement

    I'm generating attendance so I have a different set of timing example

    0800,1200,1230, 1700 and I need to insert data into the table that contains the intimate value min and max value for

    outtime and othere to inertval time in or out

    Pls tell me with some examples


    For example

    For INSERT

    Insert into T2 (barcode, empcode, respondent, attend_date)
    values (R2.cardn, R2.enpno, min(R2.) PtIMe), R2.pdate);


    Update

    Update dail_att set outtime = MAX (r2.ptime) where empcode = r2.enpno and barcode = r2.cardn and
    attend_date = r2.pdate;


    Here, in the place where I used to have so pls tell how to use

    Thanks and greetings

    Srikkanth.M

    Hi Srikkanth.M

    to insert:

    insert into test (dummy) values ((select max (dummy) to double));

    Update:

    Update test dummy value = (select max (dummy) to double where to test them. XXXXField = double. XXXXField);

  • I have an Apple computer, use the browsers Firefox and Safari, use Comcast for my email. Lately, when the Firefox, my email does not work correctly. Why?

    I have an Apple computer, use the browsers Safari and Firefox. I use Apple mail and Comcast to my email. Lately, in the case of Firefox, my email does not work correctly. I get a message "your server license has expired. While usually, I can access my emails, I can't delete the unwanted emails. This problem will not occur when I use Safari and Apple mail. Is this a problem of Firefox or Comcast? Do you know what license is expired?

    Hello

    Many issues of the site can be caused by corrupted cookies or cache. To try to solve these problems, the first step is to clear cookies and cache.
    Note: This will be you temporarily disconnect all sites, you're connected to.
    To clear the cache and cookies to do the following:

    1. Go to Firefox > history > clear recent history or (if no Firefox button is displayed) go to tools > clear recent history.
    2. Under "Time range to clear", select "all".
    3. Now, click the arrow next to details to toggle the active details list.
    4. In the list of details, see the Cache and Cookies and uncheck everything.
    5. Now click the clear now button.

    More information can be found in article to clear your cache, history, and other personal information in Firefox .

    This solve your problems? Please report to us!

    Thank you.

  • Using firefox 14.0.1. Load a link using the right click and "Open link in new window", translates into a new window opens but doesn't show URL address bar...

    Using firefox 14.0.1. Load a link using the right click and "Open link in new window", translates into a new window opens but doesn't show URL address bar. However, if I click with the right button on a link and select "Open link in a new tab", the tab displays the URL in the address bar. If it works when a new tab it's not in a new window.

    The reset Firefox feature can solve a lot of problems in restaurant Firefox to its factory default condition while saving your vital information.
    Note: This will make you lose all the Extensions, open Web sites and preferences.

    To reset Firefox, perform the following steps:

    1. Go to Firefox > help > troubleshooting information.
    2. Click on the button 'Reset Firefox'.
    3. Firefox will close and reset. After Firefox is finished, it will display a window with the imported information. Click Finish.
    4. Firefox opens with all the default settings applied.

    Information can be found in the article Firefox Refresh - reset the settings and Add-ons .

    This solve your problems? Please report to us!

  • Portege R500-11Z: how to use the external mic and hear the internal speakers

    We have a Portege R500-11Z running XP and want to use Skype with an external table microphone and the internal speakers.

    When connect us the microphone to the Jack MIC the Portege, built-in speakers cut out!

    How to use an external mic and still hear the internal speakers?

    Hello

    > When connect us the microphone on the Portege, built-in speaker MIC Jack cut!
    Are you sure you used the microphone port and no headphone port?

    Have you checked your settings Audio from Skype?
    There is an option called ring through the speaker too or something like that.

    Please also check the Realtek HD audio Manager in Control Panel.
    There is a tab called Audio i/o.

    Usually, you can change the connector settings, by clicking on the small key-tool icon.
    Disable the option called Mute rear output when plugged headphones before

    As you can see is called headset and not so I m confused a little bit why the speakers are turned off when you connect an external microphone.

    By the way; There is also a tab called micro.
    Check if the two options that reduce the echo and noise are OFF

  • Hide icon Label step using the API Testand and LabVIEW

    Hello

    can someone tell me how it is possible to hide the icon of a step label using the API Testand and LabVIEW?

    In the Teststand sequence editor, under the Label Edit tab there is a checkbox called "Hide icon". Is there something similar in the API?

    Thank you

    Yes you can, you must set the stage "ni_blank.ico" IconName property

  • How to use the OS Android and Windows on the same shelf?

    Original title: is it possible I ca use the OS android and mircosoft OS?
    Is it possible that I can used both ANDROID OS and MICROSOFT OS at the same time in my Tablet?

    You will not be able to install the Windows operating system on an Android device.

  • How to open .tif files using the Windows fax and picture viewer

    I have the file open options set to use the viewer photo and fax Windows, however, it is always opens the .tif file in a window of IE. In reading the other posts regarding this problem, I think it may be a number of MIME, but nobody published how to fix this. Can someone send please how to change the MIME type so I can open the files in the right way. I REALLY appreciate it.

    Windows XP SP3 with all updates and IE8.
    Thanks in advance,
    Eric
     
    Original title: how IE8 to open a .tif file by using the Windows fax and picture viewer?

    Hello

    I suggest that allows you to remove any CLSIDS listed under location:

    HKEY_CLASSES_ROOT Type\image/tiff
     

    Note: Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems can occur if you modify the registry incorrectly. Therefore, make sure that you proceed with caution. For added protection, back up the registry before you edit it. Then you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click on the number below to view the article in the Microsoft Knowledge Base:

    322756 (http://support.microsoft.com/kb/322756/ )

    How to back up and restore the registry in Windows.

    I hope this helps.

  • I WISH THAT ALL PAGES TO FIT ON MY SCREEN SO I CAN'T USE THE ARROW LEFT AND ARROW RIGHT! THANK YOU VERY MUCH FOR YOUR HELP!

    MY PAGES HAVE BEEN VERY WELL UNTIL I DOWNLOADED SOMETHING, I DON'T KNOW EXACTLY.   I THOUGHT I TRY TO DELETE WHAT I DOWNLOADED ARRIVE TO WHERE I WAS, BUT I DON'T THINK IT WORKED OR I DELETE ANYTHING!  SO I'M GOING TO STILL USE THE ARROW LEFT AND ARROW RIGHT TO VIEW ALL PAGES.  I WENT TO CONTROL PANEL, DISPLAY, SETTINGS, WENT TO A HIGH NUMBER TO THE PIXEL NUMBER LOW, CE WHICH WAS THE ONLY SOLUTION POSSIBLE, AND ALL GROW.  SO I PUT IT BACK TO THE LOT WHERE HE WAS!  DON'T KNOW WHAT TO DO, SO HERE I AM ASKING FOR HELP!  Thank you!!!  MY email * address email is removed from the privacy *.

    First remove everything you have installed, check if it works.

    In case of failure and then update the display on the computer drivers

  • I try to use the clean disk and after it starts I get a message that it has stopped working

    I try to use the clean disk and after it strats up, I get a message that it has stopped working

    Original title: clean work investor disc

    Please use this tutorial and try to do the cleaning disc again.

    http://www.Vistax64.com/tutorials/76073-disk-cleanup.html

  • Connect pc with win 7 to an instrument THEN use the com port and the PPP protocol

    Dear all,

    I need to make a connecting series between a pc with win 7 and one instrument.

    To achieve this I have to use the com port and Protocol PPP. In win xp is possible but I'm not able to find the same in win7

    concerning

    Diego

    Hi Diego,.

    Thanks for posting your query in Microsoft Community Forum.

    According to the description of the issue, I recommend you post your query in the TechNet Forums. TechNet is watched by other computing professionals who would be more likely to help you.

    TechNet Forum

    http://social.technet.Microsoft.com/forums/Windows/en-us/home?category=w7itpro

    Hope this information is useful.

Maybe you are looking for

  • Where to download iMovie of the Mavericks

    I tried to download iMovie on the App Store, but he wants me. I want to stay on the Mavericks. How can I get iMovie for the Mavericks? I tried to install iMovie from the original cd of app snow leopard, but it I did not install either, guess that's t

  • Satellite P750 - formatting the disk deletes C recovery files?

    I own a Toshiba Satellite P750 and I want to install Windows 8 on my laptop, I wonder if the recovery files will be deleted which is what I mean is that after formatting the C drive and install a new OS, I'll be able to restore the laptop to factory

  • Winsdows Update Error 80070020 updates yesterday against MS

    This happens only with 975560 KB that is related to MS10-013 and claims to be a critical update.All other updates are correctly loaded.There is no error message - just the fact stated that this update failed to install after reboot. - because it coul

  • the hp photosmart 8450 printer has an internal hard drive memory?

    I am have this printer and to make sure there is no personal information remaining.

  • Cisco Jabber for windows 9.6 problem

    Hello We have Cisco Unified CM Administration The system version: 10.0.1.10000 - 24   and   Cisco Unified CM IM and presence management The system version: 10.0.1.10000 - 26   We have installed a Jabber for Windows 9.6 Cisco. When I try to use the cu