How to find the rank lowest for each student using a Select query?

Hey I'm having a little trouble here

I have this table


Student - Grade

John - 8
Richard - 9
Louis - 9
Francis - 5
John - 13
Richard - 10
Peter - 12

Shades may vary from 0 to 20.

Name - varchar (50)
Grade - wide

I'm trying to generate a SQL search to search for each rank lowest for each student.

So far, I did:

Select s.name, s.grade
s student
where s.grade = (select min (grade) of student)

The result of this search returns me only the rank lowest of all ranks posted above, which is Francis - 5.

I want to find the lowest rank, but not only for Francis, but for all students in the table.

How do I do that?

Thank you in advance.

Ok

Now we head into analytical SQL:

with student as (select 'John' name, 8 grade, 'fail' result from dual union all
                 select 'John' name, 13 grade, 'pass' result from dual union all
                 select 'Francis',     5 grade,  'fail' from dual union all
                 select 'Peter', 12, 'pass' from dual)
-- End of your test data
SELECT   name,
         MAX (result) KEEP (DENSE_RANK FIRST ORDER BY grade) result,
         MIN (grade) min_grade
FROM     student
GROUP BY name

Please note that I passed ;)

Concerning
Peter

To learn more:
http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/functions056.htm#SQLRF00641

Tags: Database

Similar Questions

  • How to find the child level for each table in a relational model?

    Earthlings,

    I need your help, and I know that, "Yes, we can change." Change this thread to a question answered.

    So: How to find the child level for each table in a relational model?

    I have a database of relacional (9.2), all right?
    .
         O /* This is a child who makes N references to each of the follow N parent tables (here: three), and so on. */
        /↑\ Fks
       O"O O" <-- level 2 for first table (circle)
      /↑\ Fks
    "o"o"o" <-- level 1 for middle table (circle)
       ↑ Fk
      "º"
    Tips:
    -Each circle represents a table;
    -Red no tables have foreign key
    -the picture on the front line of tree, for example, a level 3, but when 3 becomes N? How is N? That is the question.

    I started to think about the following:

    First of all, I need to know how to take the kids:
    select distinct child.table_name child
      from all_cons_columns father
      join all_cons_columns child
     using (owner, position)
      join (select child.owner,
                   child.constraint_name fk,
                   child.table_name child,
                   child.r_constraint_name pk,
                   father.table_name father
              from all_constraints father, all_constraints child
             where child.r_owner = father.owner
               and child.r_constraint_name = father.constraint_name
               and father.constraint_type in ('P', 'U')
               and child.constraint_type = 'R'
               and child.owner = 'OWNER') aux
     using (owner)
     where child.constraint_name = aux.fk
       and child.table_name = aux.child
       and father.constraint_name = aux.pk
       and father.table_name = aux.father;
    Thought...
    We will share!

    Thanks in advance,
    Philips

    Published by: BluShadow on April 1st, 2011 15:08
    formatting of code and hierarchy for readbility

    Have you looked to see if there is a cycle in the graph of dependence? Is there a table that has a foreign key to B and B has a back of A foreign key?

    SQL> create table my_emp (
      2    emp_id number primary key,
      3    emp_name varchar2(10),
      4    manager_id number
      5  );
    
    Table created.
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  create table my_mgr (
      2    manager_id number primary key,
      3    employee_id number references my_emp( emp_id ),
      4    purchasing_authority number
      5* )
    SQL> /
    
    Table created.
    
    SQL> alter table my_emp
      2    add constraint fk_emp_mgr foreign key( manager_id )
      3         references my_mgr( manager_id );
    
    Table altered.
    
    SQL> ed
    Wrote file afiedt.buf
    
      1   select level lvl,
      2          child_table_name,
      3          sys_connect_by_path( child_table_name, '/' ) path
      4     from (select parent.table_name      parent_table_name,
      5                  parent.constraint_name parent_constraint_name,
      6                  child.table_name        child_table_name,
      7                  child.constraint_name   child_constraint_name
      8             from user_constraints parent,
      9                  user_constraints child
     10            where child.constraint_type = 'R'
     11              and parent.constraint_type = 'P'
     12              and child.r_constraint_name = parent.constraint_name
     13           union all
     14           select null,
     15                  null,
     16                  table_name,
     17                  constraint_name
     18             from user_constraints
     19            where constraint_type = 'P')
     20    start with child_table_name = 'MY_EMP'
     21*  connect by prior child_table_name = parent_table_name
    SQL> /
    ERROR:
    ORA-01436: CONNECT BY loop in user data
    

    If you have a cycle, you have some problems.

    (1) it is a NOCYCLE keyword does not cause the error, but that probably requires an Oracle version which is not so far off support. I don't think it was available at the time 9.2 but I don't have anything old enough to test on

    SQL> ed
    Wrote file afiedt.buf
    
      1   select level lvl,
      2          child_table_name,
      3          sys_connect_by_path( child_table_name, '/' ) path
      4     from (select parent.table_name      parent_table_name,
      5                  parent.constraint_name parent_constraint_name,
      6                  child.table_name        child_table_name,
      7                  child.constraint_name   child_constraint_name
      8             from user_constraints parent,
      9                  user_constraints child
     10            where child.constraint_type = 'R'
     11              and parent.constraint_type = 'P'
     12              and child.r_constraint_name = parent.constraint_name
     13           union all
     14           select null,
     15                  null,
     16                  table_name,
     17                  constraint_name
     18             from user_constraints
     19            where constraint_type = 'P')
     20    start with child_table_name = 'MY_EMP'
     21*  connect by nocycle prior child_table_name = parent_table_name
    SQL> /
    
           LVL CHILD_TABLE_NAME               PATH
    ---------- ------------------------------ --------------------
             1 MY_EMP                         /MY_EMP
             2 MY_MGR                         /MY_EMP/MY_MGR
             1 MY_EMP                         /MY_EMP
             2 MY_MGR                         /MY_EMP/MY_MGR
    

    (2) If you try to write on a table and all of its constraints in a file and do it in a valid order, the entire solution is probably wrong. It is impossible, for example, to generate the DDL for MY_EMP and MY_DEPT such as all instructions for a table come first, and all the instructions for the other are generated second. So even if NOCYCLE to avoid the error, you would end up with an invalid DDL script. If that's the problem, I would rethink the approach.

    -Generate the DDL for all tables without constraint
    -Can generate the DDL for all primary key constraints
    -Can generate the DDL for all unique key constraints
    -Can generate the DDL for all foreign key constraints

    This is not solidarity all the DOF for a given in the file object. But the SQL will be radically simpler writing - there will be no need to even look at the dependency graph.

    Justin

  • SQL - find the minimum value for each separate record...

    Hi all

    I have a table like this in SQL Server

    Date of sale of product
    A date
    A date
    A date
    B date of
    B date of
    C date
    C date
    C date

    I would like to write a query to find the minimum date (i.e. the date
    the first sale) for each product

    Thus, the expected results would be

    Date of sale of product
    A date min
    B date of min
    C date of min

    How can I do this using SQL Server?

    any help is greatly appreciated!

    Thank you!

    Product SELECTION, MIN (sale_date)
    From your_table
    GROUP BY product

    Etienne

  • How to find the audio driver for HP sleekbook

    Can not find the audio driver for my HP laptop...

    I bought the new elegant book, model no HP. Elegant Pavilion book 15th-b001

    After 2-3 months, I found my laptop speakers weren't working and its got very slow. I couldn't do so I kept using headphones.
    recently, I've run the driverpack and accidentally a few update audio driver and voice my laptop has increased incredibly, I was surprised, it was very good,

    but now, I've updated my windows 8 to 10 and all the previous driver deleted and voice became too slow as it used to be.,.
    now I run the driverpack 15 which is a more up-to-date version, but they did not update this driver, and always the voice of my laptop is too slow.
    I don't know the exact name of that drivers, how do I know the name of that drivers?
    on the internet, I tried too many drivers audio, high definition, etc., but the result is zero,
    con someone help me about this?

    http://ftp.HP.com/pub/SoftPaq/sp59501-60000/sp59802.exe

  • How to find the latest diagnostics for 11i patches

    How to find the latest patches of diagnostics for 11i, all documents.

    You can find the latest patch in (Note: 167000.1 - Guide of Installation of E-Business Suite Diagnostics).

    You can also check (Note: 235307.1 - E-Business Suite Diagnostics Tools FAQ and Troubleshooting Guide for version 11i and R12).

    Thank you
    Hussein

  • NB200 - how to find the 3G module for it?

    Hello

    Pls how I find the 3G module in my NB200 - PLL20E?

    Thank you

    Hello

    What do you mean exactly?
    You want to upgrade your NB200 with a card 3G?

    If yes then you must make sure that your NB200 could be improved using this card.
    I'm not sure if this is possible.

    But don t give up boyfriend Toshiba authorized service partner in your country could provide details.
    Guys might be able to tell if this is possible and could provide a good 3G module

    If you get more details please share with us!

    See you soon

  • How to add the action button for each column in the interactive report

    Hi all

    I'm new in APEX, so pls forgive my question, if it's simple, but I am struggling with this problem for days now. I have interactive report and you want to add button in each row. What I want to do with this button is the following:

    1. to execute some stored procedure in need of that particular line item values

    2. returns a (id)

    3. go in another page in the application by passing the value out of the procedure (id).

    and I'm not find the way to do it. I tried now means:

    1. If I add the link of the column, so I can refer to the value of the current row, I don't know how to call the stored procedure and perform actions of rest I need

    2. If I add the button to the region, I do not know how to reference the values in column of a particular line of the interactive report...

    and I'm stuck...

    I just forms and global report and probably still think the "wrong" way .

    Any help would be appreciated!

    Thank you!!!


    user3253917 wrote:

    Please update your forum profile with a real handle instead of 'user3253917 '.

    I request of the company: there is a customer who always orders the same standard product orders (always order the same products, fair amount is different). I want to make it simple for the user: instead of retyping the command (master and few records details every time yet) I want to copy selected command (copy of the master record and record details) so that the user will only change date order (in master record) and amount fields in record details).

    So, in order to give him:

    1. the user must be able to choose the order in which I would copy (at page 4), select it,

    2. I need to make PL/SQL procedure to insert the new master record (order) and a few record details (order_items) (copy of the order/order_items chosen in step 1)

    3. navigate the user to page 29, where the master account at stage 2 insterted appears, so that the user can change the date and quantities.

    Any solution will be highly appreciated! Thank you very much!!!

    In simple terms:

    1. Add a link to column "Command copies" in the report on page 4, which sets the COPY request and passes the order ID on page 29.
    2. On page 29, create a process before header, sequenced to be the first process executed and conditional on REQUEST be EXEMPLARY, which creates a new order as a copy of the order with the ID from page 4 and returns the ID of the new order in the PK command ID of 29 page element.
  • How to find the product key for pre-installed WIndows 7 Home Premium?

    I bought a laptop that was provided with Windows Home pre-installed permium.

    How can I load Windows once more, because I don't have the key? How can I find the key on my laptop?

    Look for the COA sticker, normally at the bottom or in the battery compartment:

    COA certificate of authenticity:

    http://www.Microsoft.com/howtotell/content.aspx?PG=COA

    What is the certificate of authenticity for Windows?

    http://Windows.Microsoft.com/en-us/Windows7/what-is-the-Windows-certificate-of-authenticity

  • How to find the source files for import

    I have difficulties to find a group of records after I imported the bridge to lightroom.  Records are in bridge and appear in my Explorer of files (windows 10).  I have number of file folders 1-12 for each month of the year.  Until recently all my subfolders in monthly records were available.  If I make an order import and select the drive C all records are there. After the import my files in the browser do not reflect the new folder.  He has always worked in the past, but now I can't for files and folders just imported.

    If I look at the previous import at the top of the browser, the images are in lightroom but I can't find them in the folder that I imported them.  The folder does not appear.

    Any ideas?

    Thank you

    Don

    Hi donm,.

    You can just + click or Ctrl + click on the folder in the library and go to the option 'Show in Explorer' or 'Show in Finder' to see the exact location of this folder on the disc.

    See the screenshot below

    Let us know if that helps.

    Kind regards

    Mohit

  • How to find the serial number for old acrobat version

    Hello

    I have an official serial number for acrobat 9 based on an acrobat upgrade older 6. But for the last I 'can' t find the serial number... How to get it?

    If you purchased or registered with adobe, make sure the account used at the time, Adobe ID

    If its currently installed on an old computer, it can be retrieved from this computer.

  • How to find the serial number for Lightroom 6 autonomous

    I just bought a stand-alone version of Lightroom 6 complete installation in a box retail and try to install it on a Windows machine.

    The installer is one displayed a screen with 6 small boxes where I enter the serial number.  This file on the DVD provided says "You can find the serial number of 24 digits (e.g. 0000 0000 0000 0000 0000 0000) on the back of your door-DVD".  I guess that means that the white paper envelope which contained the DVD.

    There is no number of 24 digits on the envelope.  The back of the envelope contains a small sticker on the lower right corner with two lines.

    -The first line contains a start with the number 9 eight-digit number.

    -The second line contains a mix of 30 letters and special characters starting with DVS/A, LTRM, 6.0, etc.

    (I did not provide the full character set snacks is a unique code for this DVD.)  Please let me know if it needs more.)

    The installation program will accept only characters alpha, only numbers.  Could you please tell me how to locate the 24 digit number he needs.  I can't find it on the envelope.  The box of the product has an Adobe sticker o back, with multiple numbers, but none is a 24 digit number.

    Your help would be appreciated.

    Thank you.

    Problem solved.

    Found the number on the secondary area containing the DVD.

    What is confusing is yesterday I installed Photoshop Elements and the serial number sticker was on the back of the envelope of white paper, not the box insert, so that's where I was initially looking for her.  It's just the opposite for Lightroom.  My suggestion would be to do the things constantly between products.

    Thank you

  • How to find the value duplicate of each column.

    I have it here are four columns,
    How can I find the duplicate of each columns value.

    with All_files like)
    Select ' 1000 'like BILL, "2000" AS DELIVERYNOTE, CANDELINVOICE ' 3000', '4000' CANDELIVERYNOTE of all union double
    Select ' 5000 ', ' 6000', ' 7000 ', ' 8000' Union double all the
    Select '9000 ', '1000', '1100',' 1200' from dual union all
    Select ' 1200 ', ' 3400', ' 6700 ', ' 8790' Union double all the
    Select ' 1000 ', ' 2000', ' 3000 ', ' 9000' Union double all the
    Select '1230', '2340', ' 3450 ', ' 4560' double
    )
    SELECT * from All_files


    Output should be as shown below.

    1000 2000 3000 4000
    9000 1000 1100 1200
    1200 3400 6700 8790
    1000 2000 3000 9000

    Required to check uniqueness columns.

    Thank you.

    Hello

    If you are not too concerned about performance, this should give you the desired result:

    SELECT distinct INVOICE, DELIVERYNOTE, CANDELINVOICE, CANDELIVERYNOTE
    FROM (
      SELECT a.*,
             count(*) over(partition by t.column_value) cnt
      FROM All_files a,
           table(
             sys.odcivarchar2list( a.INVOICE
                                 , a.DELIVERYNOTE
                                 , a.CANDELINVOICE
                                 , a.CANDELIVERYNOTE ) ) t
    )
    WHERE cnt > 1
    ;
    
  • How to remove the "subject" prefix for each message list in thunderbird

    Hello.
    It seems now that on the screenshot.
    In each row shows "object:" prefix. I have not found in thunderbird not google how to disable.
    Help, please.

    It is not a built-in feature, so I suspect an add-on, possibly from Conversations. Run Safe Mode (hold SHIFT when you start TB) and see if it persists.

  • How to find the exact motherboard for Satellite P100-347 model?

    Hello
    I hope someone could help me. I'm looking for a new motherboard for my computer toshiba laptop because it replaced needs.

    I own a laptop Satellite P100-347 of pspa6e-03302cen and have not been able to find this anywhere online forum. Although I found two suppliers of many motherboards of p100, they use numbers of alternative model in which I can't find anywhere in my documents or on the computer. The model numbers they use are something like A000008350 or a number starting with k. I'm sure that the supplier I found has the motherboard, I would need but I would need a list of all the numbers of the other party for my laptop, or a way to find the exact numbers. Any help on this is appreciated...
    Thank you

    To be honest I really don't think that someone here can offer you this info. As you know, this info is for internal use and you can try to get this info from service provider authorized in your country. Sorry, but I don't see a better solution, except to wait here and hope someone can help.

    Good luck!

  • How to find the license key for WINDOWS 8.1 which was preinstalled?

    I bought a Dell Inspiron laptop 14-5447 which has 8.1 pre-installed WINDOWS. I made a recovery disk, but I could not find anywhere license key. I don't need to have a license key, if I ever need to re - install the OS? How can I find the license key? Thank you

    The key is stored in THE system BIOS, and is read automatically during a re - install if necessary.  You can see the key using one of the utilities such as Belarc Advisor free system scan.

Maybe you are looking for

  • hp scanjet 4670: hp scanjet 4670 image - scanned split

    The picture says it all - that someone knows what's the problem and how to fix it - product hpscanjet4670 - was a brilliant scan until yesterday (think it might be the cable)

  • scam or legit?

    Someone asked saying me that they are from technical support and my computer has a serious infection. They wanted me to compare my CLSid. Microsoft never does the calls of this nature?

  • Windows media player artists name has additional symbol at the end

    In Windows Media Player, a little square symbol follows the name of the artist on some of the entries.  I try to remove it and it comes back.  This translates to a separate artist for a few songs in the same album.  Also, if I try to display songs fr

  • I can't install my Razer Naga Epic driver

    When I run the file I get this error "{1152: error extracting C:\users\neospe~1\AppData\Local\Temp\{3a...}" in the temporary location "anyone how to solve this problem." IM using Vista 64

  • Several questions to Xperia Z3

    Hello Recently I bought the z3 Xperia but facing many questions. Can anyone help. 1 battery draining fast. A few minutes of charging to 100%, it reduces of 95% and lower. tried several solutions for energy consumption and uninstalled facebook, messen