Two 'sum' s with different requirement for each

Hello...

I am trying to create some statistical queries (reports) using the Oracle10g database
and I was wandering if it was possible for me to create a query "select' with 2 'Sum' function in it to be manipulated under certain conditions.
Here is my case and I'm trying to do.

Lets assume that I have a (STUDENTS) table that contains the information for a students of the University as follows

Students
-----------------
stud_no
between the sexes
main
.. .etc

what I'm trying to do is to get a statistical report for the number of students grouped by the 'major' for each 'sex', there is no training with me using Group By, but I managed to get this way:

SELECT DISTINCT MAJOR,

(SELECT COUNT (STUD_NO)
STUDENTS
WHERE MAJOR = A.MAJOR AND SEX = am') "MALE_COUNT."

(SELECT COUNT (STUD_NO)
STUDENTS
WHERE MAJOR = A.MAJOR AND SEX = 'f') "FEMALE_COUNT".

STUDENTS HAS
ORDER BY A.MAJOR

Is there a more effective way to achieve the same result? I am so concerned about the problem of performance, as it is so important to the system.
SELECT  A.MAJOR,
        SUM(CASE A.GENDER WHEN 'm' THEN 1 ELSE 0 END) MALE_COUNT,
        SUM(CASE A.GENDER WHEN 'f' THEN 1 ELSE 0 END) FEMALE_COUNT
  FROM  STUDENTS A
  GROUP BY A.MAJOR
  ORDER BY A.MAJOR
/

SY.

Tags: Database

Similar Questions

  • LINES in COLUMNS with different values for each column (after division)

    Hello
    I have a table called summary where I produced, month, value,.

    When I used select * tab, I get months jan, Feb, mar, Apr. I wrote a query to get the months(jan,feb,...) columns

    SELECTmax (DECODE(ROWNUM,1,month)) Column1
    + Max (decode(rowNum,2,month)) table Column2 +.

    as this up to 12 months
    After that, I want to get the NEWVALUE for each month.
    I wrote a query to get the value, but I get the value only for the first month, and for the rest, I get NULL values.

    Select max (DECODE(ROWNUM,2,vallue)) Column1, Column2 of max table (DECODE(ROWNUM,3,vallue))



    Is it possible to get the newvalues for each month (in sql only) if so, please help me

    Thank you
    Chand
  • the list widget with different colors for each item in the list?

    I'll add a widget list to my interactive color wheel:

    * http://r0k.us/graphics/SIHwheel.html

    It is an old applet, first published in 1998 and older than Swing.

    The list contains the names of color 1 567 which he knows the color values. I want the background color to each element to be one of the named color. The forefront color name text will be white or black, chosen for readability to her background. Basically, I'm hoping to accomplish what the name of this color page did with its list widget HTML-form:

    * http://chir.ag/projects/name-that-color/

    I studied the java.awt.list document:

    * http://download.oracle.com/javase/1.4.2/docs/api/java/awt/List.html

    SetBackground() and setForeground() methods are implemented, but they seem to apply only to the list as a whole. As far as I know, it seems there is no access to list items themselves as components. I hope that I am just missing what is obvious.

    -Rich

    What you want to do can be easily implemented on a JList swing, with the help of a custom converter. I would advise therefore to rewrite your applet in the swing, then use a JList. That way you can skip JUnit is studying just to force your applet awt to do something of awt was neither designed for and focus on swing of things GUI. Below is an example of how you can implement your JList:

    import java.awt.*;
    import java.math.BigInteger;
    import java.util.Arrays;
    import java.util.Comparator;
    
    import javax.swing.*;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    
    public class ColorList {
    
        public static void main(String[] args) {
         SwingUtilities.invokeLater(new Runnable() {
    
             @Override
             public void run() {
              new ColorList().createGUI();
             }
         });
        }
    
        private void createGUI() {
         String[][] array = getArray();
         // sort the array as you wish
         Arrays.sort(array, new Comparator() {
    
             @Override
             public int compare(String[] o1, String[] o2) {
              return o1[1].compareTo(o2[1]);
             }
    
         });
         // create the JList
         final JList list = new JList(array);
         // set some adequate renderer
         list.setCellRenderer(new DefaultListCellRenderer() {
             private static final long serialVersionUID = 1L;
    
             @Override
             public Component getListCellRendererComponent(JList list,
                  Object value, int index, boolean isSelected,
                  boolean cellHasFocus) {
              DefaultListCellRenderer renderer = (DefaultListCellRenderer) super
                   .getListCellRendererComponent(list, value, index,
                        isSelected, cellHasFocus);
              renderer.setText(((String[]) value)[1]);
              int color = new BigInteger(((String[]) value)[0], 16)
                   .intValue();
              renderer.setBackground(new Color(color));
              renderer.setForeground(new Color(0xFFFFFFFF ^ color));
              return renderer;
             }
         });
         final JLabel demoLabel = new JLabel(
              "Display this text in the selected color", JLabel.CENTER);
         list.addListSelectionListener(new ListSelectionListener() {
    
             @Override
             public void valueChanged(ListSelectionEvent e) {
              String[] selected = (String[]) list.getSelectedValue();
              demoLabel.setForeground(new Color(new BigInteger(selected[0],
                   16).intValue()));
             }
         });
    
         JFrame frame = new JFrame("ColorList");
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.add(new JScrollPane(list), BorderLayout.LINE_START);
         frame.add(demoLabel, BorderLayout.CENTER);
         frame.pack();
         frame.setLocationRelativeTo(null);
         frame.setVisible(true);
        }
    
        private String[][] getArray() {
         return new String[][] {
    
         { "000000", "Black" },
    
         { "000080", "Navy Blue" },
    
         { "0000C8", "Dark Blue" },
    
         { "0000FF", "Blue" },
    
         { "000741", "Stratos" },
    
         { "00FF00", "Green" },
    
         { "FF0000", "Red" },
    
         { "FFFFF0", "Ivory" },
    
         { "FFFFFF", "White" }
    
         };
    
        }
    
    }
    

    Piet

  • How to acquire of various AI channels simultaneously with a different range for each of them?

    How to acquire of various AI channels simultaneously with a different range for each of them?

    In LabView, I found some examples but in C it is not seem to be any.

    Or you can add channels one by one with individual instructions: the follwing code compilation and runs without error on vitual DAQ hardware:

    ERR = DAQmxCreateTask ("", &taskH); ")
    ERR = DAQmxCreateAIVoltageChan (taskH, ' Dev1/ai0', 'AI0', DAQmx_Val_Cfg_Default,-5,0, 5.0, DAQmx_Val_Volts, "");
    ERR = DAQmxCreateAIVoltageChan (taskH, ' Dev1/ai1', 'AI1', DAQmx_Val_Cfg_Default,-10,0, 10.0, DAQmx_Val_Volts, "");
    DAQmxStartTask (taskH);
    ERR = DAQmxReadAnalogF64 (taskH, 5, 10.0, DAQmx_Val_GroupByChannel, val, 10, & read, 0);
    DAQmxClearTask (taskH);

  • [REQUEST] Different images for each parent of the field of the tree?

    How can I provide different pictures for each parent/root of the field of the tree?

    I finally understand it.

    This is my code:

       public static class TreeCallback implements TreeFieldCallback {
            // The "drawTreeItem" method is invoked
            // when a treefield item requires painting.
            public void drawTreeItem(TreeField tree, Graphics g, int node, int y,
                    int width, int indent) {
                // Retrieves the user-supplied cookie object
                // for the given node and casts to a string.
                String text = (String) tree.getCookie(node);
                Bitmap b;
                g.setColor(Color.ANTIQUEWHITE);
                // Draws the text of the treefield item.
                if (text.equals("First Parent")) {
                    b = Bitmap.getBitmapResource("your_first_bitmap");
                    g.drawText(text, indent + b.getWidth() + 20, y + 15);
                    g.drawBitmap(indent + 15, y, b.getWidth() + 5, b.getHeight(),
                            b, 0, 0);
                } else if (text.equals("Second Parent")) {
                    b = Bitmap.getBitmapResource("your_second_bitmap");
                    g.drawText(text, indent + b.getWidth() + 20, y + 15);
                    g.drawBitmap(indent + 15, y, b.getWidth() + 5, b.getHeight(),
                            b, 0, 0);
                } else {
                    b = Bitmap.getBitmapResource("your_default_bitmap");
                    g.drawText(text, indent + b.getWidth() + 50, y + 15);
                    g.drawBitmap(indent + 40, y, b.getWidth() + 5, b.getHeight(),
                            b, 0, 0);
                }
            }
        }
    
  • Cisco ISE 1.3 - Mab authentication with a vlan for each foor

    Hello

    A client wants to implement authentication MAB with a vlan for each floor. I found a solution of Loïc

    I have set up the following:

    -the profile of different authentication with a vlan different.

    -Add the endpoint (printer etc) endpoint identity.

    -create endpoint group identity that end point of recall.

    -create a rule to authorizzation reminding all work and element... in the end.

    Do you know if there is a faster way where another way to solve the problem?

    Thank you all

    Well, mab in some environments, could be replaced by profiling and for rules, rather af with a rule authz for each floor, you can name your VLAN in your eponymous switches to "Printers", in the world, then you would only need an authz rule, where you use the name of the vlan instead of identification number, so no matter where this printer , it will end in the vlan 'Printer', whatever it is in this specific switch.

  • How can I create a slide show 100% width, but have the caption in different positions for each slide.

    How can I create a slide show 100% width, but have the caption in different positions for each slide.

    There is placement of the legend only one for all the images in a slide show.

    The slideshow widget is specialized to create slideshows of the image. The widget of composition is a much more flexible widget which allows any combination of images and text in the trigger containers or containers of target of the widget. A widget of composition could be used to create a slide show with several legends by image and/or legends of different places for each image. The disadvantage of the widget of composition is that, due to the nature flexible widget, very little is automated for you and so it is much more intensive work to create a slideshow of images using the widget of composition.

    Thank you

    Sanjit

  • A license is required at the VASA? A license is required for each copy? VSI is necessary to have the VASA? They are mutually exclusive? VSI need NOTTM?

    A license is required at the VASA? A license is required for each copy? VSI is necessary to have the VASA? They are mutually exclusive? VSI need NOTTM?

    Thanks in advance.

    Assuming that you are referring to EMC arrays.

    License to the VASA: No.

    VSI required at the VASA: No. they work very well together, but does require that the other.

    VSI allowing VAAI: No. VAAI is active with or without the VSI.

  • WHY THE PGA IS REQUIRED FOR EACH USER?

    Hello everyone;

    I have a question about PGA.

    WHY THE PGA IS REQUIRED FOR EACH USER?

    What I got from google...

    Even if information analysis of SQL or PL/SQL is already available in the library of shared pool cache,

    the value that the user want to execute the statement select or update cannot be shared.

    I can't realize that someone can show an example of clear, if possible?

    DB version is 10.2.0.4.0

    OS: oracle linux 5.5

    Thanks in advance...

    PGA is memory private belonging to a specific user. This private memory contains of these pieces that is not supposed to be shared with others. For example, when you sort a part of the data, that does not mean all he wants too. If Oracle retains the sorted data requested by you in your own PGA. Similarly, if you want to query a table with a value of 10, it does not mean that all want the same thing. If these structures are stored in the PGA. For a more detailed description, read the link given by Hoek.

    HTH

    Aman...

  • Export of several video tracks in 1 file with different effects on each track.

    I'm currently trying to export 3 MP4 1 video tracks.

    Each track contains exactly the same images, but with different effects for a certain aesthetic.

    When I view the sequence he first that 3 of all titles is displayed correctly.

    The exported version only seems to export the Summit track, Track3.

    Track 2 and 3 have opacity at 47%.

    Track 1 opacity is set to 100%.

    I tried to export a test project that has several layers, and it was no problem.

    I have tried exporting a test project with exactly the same opacities and effects, as it is a little of your time. So I will do if I can't get a solution of stisafctory in the forums.

    The problem, in my view, is the superposition of the effects. In this case on track 3 I have procamp, which reinforces the red in 1 layer. This is the image I get once the last piece is exported - track 3.

    Then.

    How can I get the effects of each layer to display correctly export?

    and

    Why the exported version missing securities (or the effects of the tracks) 1 and 2?

    Need to know:

    • The layer source footage
    • Effects that you use
    • How you have the sequence in place, for example how are extracted and stacked effects
    • Hardware or software MPE
    • Maximum bit depth: on or off
    • Maximum render quality: on or off
    • Destination format

    Let's start there.

  • Web Gallery - different caption for each photo - broken?

    It's something I've done successfully with versions before LR2.5 but for some reason that I cannot now create different captions for each photo.  The help page in line said: "to display a different caption or title for each photo, click on the menu of settings customized to the right of title or a legend and choose Edit. In the patterns of text editor that appears, insert the IPTC title or caption metadata element, and then click Done. »

    This does not happen.  If I create a title for the first photo, it appears for all others.  If I change the caption for the second picture, everything changes, including the first caption of the photo.  Is this a new bug, or am I just missing something?

    I can always change the HTML gallery, but it is not an elegant solution, to say the least.

    Help appreciated.

    DN

    Enter the title or caption in the library, in the metadata Panel. And select the items in the grid. The titles that you change apply to the web gallery, not the individual photos.

  • Comply with the requirements for El Capitan if I have a Mac Mini MTN. Lion and 2 GB of memory running with a 2.4 GHz Core 2 Duo?

    Comply with the requirements for El Capitan if I have a Mac Mini MTN. Lion and 2 GB of memory running with a 2.4 GHz Core 2 Duo and 1.07 GHz and 3 MB of L2 Cache bus speed? Recommend - install you more memory and if so, why?

    1. Yes.

    2. Yes. Any newer version of Mac OS X 10.6.8 is likely to be sluggish on only 2 GB of RAM.

    (141471)

  • The ipad pro supports multiple monitors with different content on each screen?

    I want to replace my laptop with an ipad pro.  Currently I drive three screens with my laptop, all with different content (VGA, HDMI, laptop screen) with no additional adapters.  The Ipad pro has a video card that will allow me to run multiple monitors (3 including the pro) with different content on each monitor?

    Given that the pro iPad running iOS and iOS do not supports multiple monitors, I would say no. I may be wrong, so feel free to correct me.

  • Try to set a different "vision" for each folder in Windows Explorer - I have Window 7

    I have Windows 7.  I'm putting each file in Windows Explorer to a specific view (for example 'list', 'Large icons', 'Détails', etc.) and I want that this point of view to apply to a single file, and I want this file to show in the view selected every time that I access.  And I want to be able to define different views for different folders.  But every time I have to change the view in a given folder, it keeps this view of every folder I open it.

    I clicked on 'Tools', then 'Folder Options', but I don't see anything that helps.

    How to set different views for each individual file?

    Thank you very much!

    G: Samhrutha

    I'm a fool lol.  I realized that I had copied my entire "My Documents" folder by mistake in the 'Documents' library, rather than simply copy a shortcut in my 'Favorites' (which is what I intend to do).  And I had tried to change all my folders by accessing them through the library instead of via the location of origin in 'My Documents '.  And the library does not change the display of each specific case.  This is why the buttons 'Apply to folders' and 'Reset records' shady and would not allow me to push, because I was in the library.

    In any case, it's all good now.  Now that I'm accessing the files from their original location in 'My Documents', it's to let me change the display of each individual file.

    Thank you very much for your help.  Without you me through these steps, I would not have stumbled on the problem.

    Thanks again!
    theokapi

  • How to set a different screen for each user profile resolution?

    original title: Troubleshooting

    Is it possible to have the accounts of differnet with different settings for screen resolutions? This is the problem, I have an Aspire that I am connected to my hd tv. This allows me to have a bigger screen, I need. A significant number of games does not work on 800 x 600. My son went through a whole bunch of options to change the resolution so that I can play these games, but all, apart from the games is smaller than a postage stamp. So if I want to play a game, I can do nothing else until someone can help me to change the resolution. Thank you.

    Judyk

    Right-click on your desktop and click on the screen resolution,

Maybe you are looking for