Calculate the MAX without using a VIEW

Is there a method to finding the Operator (OPERATORE) that respond at the maximus number of calls (CHIAMATE) without using a view like in the example?
CREATE OR REPLACE VIEW MassimoChiamate as
SELECT Operatore, Count(*) AS NUMERO_CHIAMATE
FROM Chiamata
GROUP BY Operatore;
SELECT Matricola,Cognome,Nome, numero_chiamate
FROM MassimoChiamate, Operatore
WHERE NUMERO_CHIAMATE=(SELECT Max(NUMERO_CHIAMATE) FROM MassimoChiamate) AND Matricola=Operatore
ORDER BY Operatore;where
CREATE TABLE Chiamata (
Cliente VARCHAR2(10) REFERENCES Cliente(NTelefono)ON DELETE CASCADE,
Campagna VARCHAR2(20),
Azienda VARCHAR2(20),
Operatore VARCHAR2(10) REFERENCES Operatore(Matricola) ON DELETE CASCADE,
Tipologia VARCHAR2(15) CHECK (Tipologia IN ('assistenza','informazioni','reclami', 'nulla', 'pubblicità')),
Verso VARCHAR2(10) CHECK (Verso IN ('entrata','uscita')),
DataOraInizio TIMESTAMP,
DataOraFine TIMESTAMP,
PRIMARY KEY (Cliente, Campagna, Azienda, Operatore),
FOREIGN KEY (Campagna,Azienda) REFERENCES Campagna(Nome,Azienda) ON DELETE CASCADE,
CHECK (DataOraFine > DataOraInizio)
CREATE TABLE Operatore (
Matricola VARCHAR2(10) PRIMARY KEY,
Cognome VARCHAR2(20),
Nome VARCHAR2(20),
Tipo VARCHAR2(15) CHECK( Tipo IN ('semplice','supervisor','amministratore')),
Username VARCHAR2(15),
Password VARCHAR2(15),
Responsabile VARCHAR2(10)
);

One way would be:
SELECT matricola, cognome, nome, numero_chiamate
FROM operatore o,
     (SELECT operatore, COUNT(*) numero_chiamate
      FROM chiamata
      GROUP BY operatore
      HAVING COUNT(*) >= ALL (SELECT COUNT(*)
                              FROM chiamate
                              GROUP BY operatore)) m
WHERE o.matricola = m.operatore
ORDER BY OperatoreAnother, using analytics could be:
SELECT matricola, cognome, nome, numero_chiamate
FROM operatore o,
     (SELECT operatore, RANK() OVER (ORDER BY numero_chiamate) rn
      FROM (SELECT operatore, COUNT(*) numero_chiamate
            FROM chiamata
            GROUP BY operatore)) m
WHERE o.matricola = m.operatore and
      m.rn = 1
ORDER BY OperatoreTTFN
John

Similar Messages

  • Calculate the max and sum value by weird way !!!

    this code calculate the sum value without sum clause :-
    DECLARE
    x NUMBER;
    y NUMBER := 0;
    CURSOR cur_sal
    IS
    SELECT sal
    FROM emp;
    BEGIN
    OPEN cur_sal;
    LOOP
    FETCH cur_sal
    INTO x;
    EXIT WHEN cur_sal%NOTFOUND;
    y := y + x;
    END LOOP;
    CLOSE cur_sal;
    DBMS_OUTPUT.put_line ('sum sal without using sum function = ' || y);
    END;
    and this code calculate the max value without max clause :-
    DECLARE
    x NUMBER;
    y NUMBER := 0;
    CURSOR cur_sal
    IS
    SELECT sal
    FROM emp;
    BEGIN
    OPEN cur_sal;
    LOOP
    FETCH cur_sal
    INTO x;
    EXIT WHEN cur_sal%NOTFOUND;
    IF (x > y)
    THEN
    y := x;
    END IF;
    END LOOP;
    CLOSE cur_sal;
    DBMS_OUTPUT.put_line ('max sal without using max function = ' || y);
    END;
    the Question is : how suppose that's happen ?
    what's the secret in those codes ?
    it's just new idea for me , but I don't understand !
    is there any name for this way in ( Oracle® Database PL/SQL User's Guide and Reference ) ?
    if not , so please anyone give me any help to understand those codes !

    Secret? What secret? It slowly and inefficiently fetch each row one at a time and consecutively add them together you get a sum. What the first, horribly inefficient, cursor loop is doing is roughly the equivalent of determining how many rivets are in a bucket by dumping them on the floor and picking them up one at a time rather than weighing one, weighing all, and then doing a simple division. The second loop does the same, horribly inefficient thing, by picking up each rivet and seeing if it is bigger than the previous one.
    Cursor loops are obsolete and this code is about as inefficient as you can get without using an Excel macro.

  • How to list the datasources without use a tnsnames.ora file?

    Hi,
    I want to use the OracleDataSourceEnumerator class of ODP.Net to list the datasources on which the user can connect.
    It's work with a tnsnames.ora on the local station, so good.
    But I want use the easy connect naming methode so i have edited the sqlnet.ora file with this:
    NAMES.DIRECTORY_PATH= (EZCONNECT, TNSNAMES)
    then i have deleted the content of the tnsnames.ora
    so my code don't work : none datasource is returned by the OracleDataSourceEnumerator
    So my question : is it a way to list the datasources without use a tnsnames.ora file?
    Edited by: user13499556 on 17 déc. 2010 08:21

    You can check
    DataConnectionFile.EnumerateDependants method
    This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

  • Is there any way to force the applet to load the file without using cache?

    Hi,
    I have the applet that renders some data from a file specified as the parameter. The problem is that the user can do something, that changes the input file and reloads the page, but the applet renders old data (from browser cache most probably)
    Is there any way to force the applet to load the file without using cache?
    Regards,
    Zdenek

    The initial view (IV) settings within a PDF file are static tags - they can't be made to dynamically-adapt based on the window dimensions,it's the renderer (Acrobat, Reader, or whatever else is opening the file) that decides if and how it will follow the IV requested by the file header.
    It would be possible to use a Page Open action on the first page of the file, which does some nasty math with the various doc.*WindowRect objects to work out how much "wasted" space there is, and then set the doc.layout and doc.zoomType properties - but page actions are a different concept to IV as the zoom will reset itself every time that page is viewed. Users don't like their application apparently fiddling with the zoom level without being told to!

  • Document Settings - Calculate the row total using the unit price

    Hi All,
    I'm using SAP2007A PL37, the option "Calculate the row total using the unit price" in Document Settings is no longer available.  Is there any updates on this issue?
    Thank you,

    Hi Marlon,
    In 2007A, by default, new database would be created without this
    checkbox activated.
    However, there is a way to bring this checkbox back to the configuration
    screen, even if it is a DB newly created in 2007A. In order to do so it
    is necessary to do as follows:
    1) Open B1 2007A
    2) Go to Help -> Support Desk -> Activation Request
    3) Copy the ASCII string that appears in the top textbox ("Customer
    Request Code").
    4) Open a Support ticket stating that you want the "Calculate Row Total
    by Unit Price" checkbox activated for the specified system (Copy the
    string in the step 2) into a text file and attach it to the message).
    5) VERY IMPORTANT: State in the message also the Business Impact leading to this request. In your case you should just say that your AddOn needs this option changed in order to work correctly.
    6) You will receive a reply from B1 Support with a number to be entered
    in the "SAP Support Code" textbox in Help -> Support Desk -> Activation
    Request
    7) Click on OK and the checkbox will be displayed thereafter.
    Hope this can be helpful.
    Best Regards
    Helen Sun

  • Find long running database objects over week (without using V$ views)

    find long running database objects over week (without using V$ views) as v$ views contains information only upto objects resides on main memory . I want to know the objects which takes highest time withing one week.

    Hello,
    welcome to the forum.
    This is the forum for the tool {forum:id=260}. Your question about v$views should be posted in {forum:id=61} or {forum:id=75}. There is a FAQ {message:id=9360002}: especially the part about providing essential informations like 4 digit version number :-)
    Regards
    Marcus

  • Print Crystal Report directly from C# without using Report Viewer

    Hello All,
    I need to print a crystal report directly to the printer without using ReportViewer in C#. I've a CrystalReport2(belowCode) which requires a query (Select * from JobHeader where JobNumber='J012345') to display all the data. I'm stuck with database connection
    and putting all the data to DataAdapter in C# (Below Code). I also have 8 subreports in my CrystalReport2. Can somebody please give me hand on this? I'm struggling with it. Thanks.
    Regards
    using CrystalDecisions.CrystalReports.Engine;
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    using System.Data.SqlClient;
    namespace csharp_win_printtoprinter
    /// <summary>
    /// Summary description for Form1
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    //CR Variables
    ReportDocument crReportDocument;
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.PrintDialog printDialog1;
    private System.Windows.Forms.Button button2;
    private System.Drawing.Printing.PrintDocument printDocument1;
    private CrystalDecisions.Windows.Forms.CrystalReportViewer crystalReportViewer1;
    private CrystalReport1 CrystalReport11;
    private Chart Chart1;
    /// <summary>
    /// Required designer variable
    /// </summary>
    private System.ComponentModel.Container components = null;
    public Form1()
    // Required for Windows Form Designer support
    InitializeComponent();
    // TODO: Add any constructor code after InitializeComponent call
    /// <summary>
    /// Clean up any resources being used
    /// </summary>
    protected override void Dispose( bool disposing )
    if( disposing )
    if (components != null)
    components.Dispose();
    base.Dispose( disposing );
    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor
    /// </summary>
    private void InitializeComponent()
    this.button1 = new System.Windows.Forms.Button();
    this.printDialog1 = new System.Windows.Forms.PrintDialog();
    this.button2 = new System.Windows.Forms.Button();
    this.printDocument1 = new System.Drawing.Printing.PrintDocument();
    this.crystalReportViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
    this.Chart1 = new csharp_win_printtoprinter.Chart();
    this.CrystalReport11 = new csharp_win_printtoprinter.CrystalReport1();
    this.SuspendLayout();
    // button1
    this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    this.button1.Location = new System.Drawing.Point(32, 56);
    this.button1.Name = "button1";
    this.button1.Size = new System.Drawing.Size(160, 104);
    this.button1.TabIndex = 0;
    this.button1.Text = "Print Report No Choose Printer";
    this.button1.Click += new System.EventHandler(this.button1_Click);
    // button2
    this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    this.button2.Location = new System.Drawing.Point(272, 56);
    this.button2.Name = "button2";
    this.button2.Size = new System.Drawing.Size(160, 104);
    this.button2.TabIndex = 1;
    this.button2.Text = "Choose Printer";
    this.button2.Click += new System.EventHandler(this.button2_Click);
    // crystalReportViewer1
    this.crystalReportViewer1.ActiveViewIndex = 0;
    this.crystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    this.crystalReportViewer1.Cursor = System.Windows.Forms.Cursors.Default;
    this.crystalReportViewer1.Location = new System.Drawing.Point(47, 188);
    this.crystalReportViewer1.Name = "crystalReportViewer1";
    this.crystalReportViewer1.ReportSource = this.CrystalReport11;
    this.crystalReportViewer1.Size = new System.Drawing.Size(903, 296);
    this.crystalReportViewer1.TabIndex = 2;
    // Form1
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.ClientSize = new System.Drawing.Size(1164, 505);
    this.Controls.Add(this.crystalReportViewer1);
    this.Controls.Add(this.button2);
    this.Controls.Add(this.button1);
    this.Name = "Form1";
    this.Text = "Form1";
    this.Load += new System.EventHandler(this.Form1_Load);
    this.ResumeLayout(false);
    #endregion
    /// <summary>
    /// The main entry point for the application
    /// </summary>
    [STAThread]
    static void Main()
    Application.Run(new Form1());
    private void button1_Click(object sender, System.EventArgs e)
    crReportDocument = new ReportDocument();
    //Create an instance of a report
    crReportDocument = new CrystalReport2();
    //Use error handling in case an error occurs
    try
    //Set the printer name to print the report to. By default the sample
    //report does not have a defult printer specified. This will tell the
    //engine to use the specified printer to print the report. Print out
    //a test page (from Printer properties) to get the correct value.
    System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument();
    crReportDocument.PrintOptions.PrinterName = printDocument.PrinterSettings.PrinterName;
    //Start the printing process. Provide details of the print job
    //using the arguments.
    crReportDocument.PrintToPrinter(0 ,true , 1, 1);
    //Let the user know that the print job is completed
    MessageBox.Show("Report finished printing!");
    catch(Exception err)
    MessageBox.Show(err.ToString(), "Unexpected exception");
    private void Form1_Load(object sender, System.EventArgs e)
    private void button2_Click(object sender, System.EventArgs e)
    //Open the PrintDialog
    this.printDialog1.Document = this.printDocument1;
    DialogResult dr = this.printDialog1.ShowDialog();
    if(dr == DialogResult.OK)
    //Get the Copy times
    int nCopy = this.printDocument1.PrinterSettings.Copies;
    //Get the number of Start Page
    int sPage = this.printDocument1.PrinterSettings.FromPage;
    //Get the number of End Page
    int ePage = this.printDocument1.PrinterSettings.ToPage;
    string PrinterName = this.printDocument1.PrinterSettings.PrinterName;
    crReportDocument = new ReportDocument();
    //Create an instance of a report
    crReportDocument = new Chart();
    try
    //Set the printer name to print the report to. By default the sample
    //report does not have a defult printer specified. This will tell the
    //engine to use the specified printer to print the report. Print out
    //a test page (from Printer properties) to get the correct value.
    crReportDocument.PrintOptions.PrinterName = PrinterName;
    //Start the printing process. Provide details of the print job
    //using the arguments.
    crReportDocument.PrintToPrinter(nCopy, false, sPage, ePage);
    //Let the user know that the print job is completed
    MessageBox.Show("Report finished printing!");
    catch(Exception err)
    MessageBox.Show(err.ToString());

    1. This is a VB.Net forum not a Visual C# forum. For Visual C# questions try this forum.
    Visual C#
    2. Crystal Reports are not supported by Microsoft. Therefore, unless somebody responding in the Visual C# forum has experience with whichever version of Crystal Reports you are using, you will probably not receive an answer in the Visual C# forum. SAP has
    their own assistance for Crystal Reports using Visual Studio. You can try to find an appropriate forum to ask questions in at SAP in the below link.
    SAP Community Network
    La vida loca

  • How do I transfer music from one iPhone to the other without using a laptop and will I be billed?

    How do I transfer music from one iPhone to the other without using a laptop and will I be billed?

    Download Past Purchases
    http://support.apple.com/kb/HT2519
    Or do you mean this...
    Old Phone to New Phone
    http://support.apple.com/kb/HT2109
    Also...
    It should be Noted that anything Downloaded with a Particular Apple ID is tied to that Apple ID and Cannot be Merged or Transferred to a Different Apple ID

  • I am brand new to the Ipad.  I can't use ICloud unless I upgrade my 10.5 Leopard.  Is there a way to sync documents created in Pages to the IPad without using ICloud?

    Hello.  I am a newbie to the Ipad.  I am currently working with an OS 10.5 Leopard MAC.  I understand that in order to use ICloud I would need to purchase OSX Snow Leopard and OSX Lion.  I am attempting to avoid the expense and to the extent possible sync my IPad with my MAC.  I have created documents on my MAC in pages.  Is there a way to have access to those documents on the IPad without using ICloud.
    A second question concerns web browsing, sometimes you'll open up a page or image and not know how to go back to the previous page. So do I just close and reopen safari altogether or is there another way to get to the previous page.
    Thanks for any guidance you can provide.

    Actually you can use iCloud with the Mac running OS X 10.5.8. You don't sync the documents - you upload to or download them from iCloud.
    You can open a browser on your Mac - Safari is preferred - log into icloud.com, enter your username and password, click on the iWorks icon, click on the Pages section at the top - and then you can drag documents into the browser window to upload files - and you can select a file in the cloud to download to the Mac. I do this on my iMac at work running Tiger 10.4.11. It's kind of slow - and you will get a warning that you may be using a supported browser - but it works.
    In any event, you can use iOS file sharing to send the Pages docs to your iPad. you have to connect to the Mac and do this via iTunes.
    iWork for iOS: About iTunes File Sharing
    Just tap the arrows in the toolbar in Safari to go back and forth. You can open multiple pages using tabs. tap on the + sign to add another tab in Safari.

  • Regarding reading the data from the files without using Stremas

    hai to all of u...
    here i have a problem where i have to read the data from the files without using any streams.
    please guide me how to do this one,if possible by giving with an example
    Thanks & Regard
    M.Ramakrishna

    Simply put, you can't.
    By why do you need to?

  • Include or create a view in the database and use this view?

    Well, I need to get related data of the main table from another related tables, so one way to do that is to use the Include method in Entity Framework to get this related data.
    However, I am thinking in another option, create a view in the database and use this view in entity framework. In this way, I avoid the needed of the include, because I think that is expensive in resources. But I am no very sure about that.
    I would like to know if the use of views on entity framework is a good idea to improve the performace or is better to use the include.
    For example, if I use the include I have the advantage that I get only one the main record and all the related data I have in the navigation properties, so the info is more shorted.
    Which is the advanteges and disadvantages of both methods to get related data in entity framework?
    Thank so much.

    Hello ComptonAlvaro,
    >>I would like to know if the use of views on entity framework is a good idea to improve the performace or is better to use the include.
    If your view would use a Join syntax to query master-child relationship tables, it actually is similar with the Include() method which actually results a duplicate records from master table, you could check this
    link for detail description.
    >>Which is the advanteges and disadvantages of both methods to get related data in entity framework?
    One visible difference is that records from Views are not editable by default(if you want edit them, you could refer to this
    blog).
    In your case, my suggestion that you could use the lazying load which will load the matter table once and disable the trace if you only need to display data.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • I want to upgrade my phone to the 4 or 4s.  My macs are still running Tiger.  If I bought an iPad 2, could I sync everything to it from the 4 without using a Mac at all, and then be able to iCloud my calendar and contacts, etc?

    I want to upgrade my phone to the 4 or 4s.  My macs are still running Tiger.  If I bought an iPad 2, could I sync everything to it from the 4 without using a Mac at all, and then be able to iCloud my calendar and contacts, etc?

    Radiation Mac wrote:
    And you must be using a recent version of iTunes on your iMac in order to activate the iPad,  So, no.
    You don't need a computer to activate a new iOS device anymore. Anything with iOS 5 can be activated over a WiFi network (or cellular if that applies).

  • I have an Apple Powerbook G4, and my monitor doesn't function. I have an external display Monitor, however it's stuck in extended screen mode. How do I get it to mirror or duplicate the display without use of the on-board?

    As i had said, I have an Apple Powerbook G4, and my monitor doesn't function. I have an external display Monitor, however it's stuck in extended screen mode. How do I get it to mirror or duplicate the display without use of the on-board? Is there a Fn key combo i'm missing or is the issue more serious then i realize? any and all help and hints would be greatly apprichiated, thanks in advance.
    -Powerbook User

    The PowerBooks have an F-key that toggles mirrored and extended mode. My PB is loaned out right now but I think it was f7. The keycap has an icon on two overlapping rectangles, as I recall.
    EDIT: Yes! Found a pdf of the PB manual it shows F7 is the toggle:

  • Import roles to the ERM without using the "Mass Role Import

    Hello,
    I want to know if there is another way to import roles to the ERM without using the "Mass Role Import.
    Im'm using SAP GRC AC 5.3
    Best Regards.
    Pablo Mortera.

    Hi.
    There is NO other way to import roles..
    We need to use only ERM for "Mass Role Import.
    Regards
    Gangadhar

  • Captivate 5.5 is setting a Mastery Score in the Manifest when using Slide Views

    We have encountered a problem with Captivate 5.5 where it is setting the Mastery Score in the manifest to match the Quiz score setting even though we are only using slide views to track completion.  This is a problem because if we set the score to zero, our Saba LMS will immediately grant the user credit for the course on the first slide.  If we set the score higher than zero, the user will never get credit for the course as Captivate doesn't send a score to the LMS when using slide views to track completion.  Our LMS seems to ignore the status passed by the course once the Mastery Score is set.  We have compared the manifest behavior in 5.0 and it does NOT set the Mastery Score.  We can edit the manifest prior to loading in the LMS but this is a hassle and we'd like to figure out a way to permanently change the behavior to no longer set Mastery Score when using Slide Views to track completion.

    Hi,
    I believe the easiest way to do this is to edit the manifest.xml file in the Captivate Templates folder.  I posted instructions on doing that here: http://forums.adobe.com/thread/956390?tstart=0
    Hope this solves your issue.  V

Maybe you are looking for

  • Why doesn't iMovie use ProRes 422 or native instead of AIC

    Does anybody know why apple still uses AIC to transcode all captured video streams instead of ProRes 422? And why does it transcode in the first place? Why can't they use the native HDV or AVCHD streams? I know that using native HDV, and especially A

  • Pse 7 with windows live mail

    I just upgraded my vista version to windows 7 and now using windows live mail.  I use pse7 for my editing program.  When I go to send an email attachment from my organizer I now must use adobe email since windows live mail is not an option.  My quest

  • How to install from FCP 1 via upgrades to FCP 3 on new G4

    I finally bought a new Powerbook G4 to replace my G3 350. (It really is it quite a bit better... Amazing how things have come along in six years...) Anyway, I started with FCP when it first came out with version 1 and bought upgrades for 2 and 3 whic

  • NME-NAM with Cisco Prime 5.1.2 and IOS Firewall

    Hello, I have installed and configured the Cisco NME-NAM with Prime 5.1.2 and have access to the NAM via a web browser. It is not picking up any data even though I havew configured the following: internal data source network site 10.10.16.0/20 All re

  • N80 stuck in Offline mode

    Hi, have already searched all over the net and on these boards to find a reason and solution but nothing concrete as of yet. First off I have had my N80 on Vodafone contract for about 5 weeks without any major problems apart from poor coverage changi