How to create a Top 10 based on values from a database?

I have a database table that stores scores for events, like a rating system.
Users choose an event they want to score, enter their score/rating and insert this into the database table.
This gives me, in my table:
Event - Rating - User
Soccer - 5 - Joe Public
Soccer - 4.5 - Jane Public
Tennis - 3 - Joe Public
...and so on.
I would like to do two things.  Firstly, I need to calculate the average for each event, which is easy enough, although I haven't quite got my head around the GROUP BY clause which, as I understand it, only allows me to use one database field?
Secondly, I would like to display, dynamically from the database, a list of top 10 events based on the results of the average ratings.
How easy is this to achieve?  I'm using ASP/VBScript and MSSQL database.
Appreciate any advice offered.  Thanks.
Regards
Nath.

Hi.  Here is what I've got, so far, to calculate the average:
SELECT     AVG(mgscore) AS mgAVGscore, mgmovieID, mgmovie, mgmovierelease
FROM         dbo.MGreviews
GROUP BY mgmovieID, mgmovie, mgmoviecert, mgmovierelease
How would I then run the RANK function?  Here's the example you provided:
SELECT RANK() OVER (ORDER BY Age) AS [Rank by Age],
       FirstName,
       Age
  FROM Person
I've tried this:
SELECT     RANK () OVER ORDER BY AVG(mgscore) AS mgAVGscore AS [Rank by Score], mgmovieID, mgmovie, mgmovierelease
FROM         dbo.MGreviews
GROUP BY mgmovieID, mgmovie, mgmoviecert, mgmovierelease
...but this produces the following error:
Error in list of function arguments: 'AS' not recognized.  Can you help?  I'm not sure I'm quite understanding how the RANK function works.
Much appreciate.
Regards
Nath.

Similar Messages

  • How to create a LookUp field, selecting a value from another record type ??

    Hello all,
    I am looking to create a new field in Opportunity in CRM On Demand where we can give the user an option to select one of the records. Data in this search applet should come from another Record Type in CRM On Demand. I am not able to find any similar literature in the Help books.
    I would appreciate if somebody could give me real life steps please.
    Thanks a lot

    Okay. I found the solution to this.
    Now, along with this single reference, we also wish to bring the values of some more joined fields from the other record type in the Opportunities screen.
    We were hoping that the Default value, and using fx, we should be able to achieve this using "joinedfieldvalue". However, it's not bringing back any value. Our expression is -
    JoinFieldValue('<CustomObject3>',[<CustomObject3Id>],'<stState_ITAG>')
    Please help if you have done this before.
    Thanks & Regards

  • How to creat a Data provider  based on different fields in SAP BW ?

    Hi,
    Experts,
    There are  20 fields  of  Plant Maintainace  like : 
    SWERK
    BEBER
    STORT
    TPLNR
    EQUNR
    INGRP
    QMDAT   ---peroid
    STTXT
    QMDAT  - Date of Notification
    QMNUM
    QMTXT
    QMART
    AUSVN
    AUZTV
    AUSBS
    AUZTB
    AUSZT
    ERNAM
    QMDAB
    AUFNR
    I  want to creat a  Report based upon these fields  ?
    For that I h'v  checked the relevant Fields to the   existing standard  Datasource  in Bw side   &
    Checked  cubes   created  based upon these Datasource  in Bw side !
    i h'v found  some fields are  existing different cubes & some are  missing .
    How to creat a Data provider  based on different fields in SAP BW ?
    plz suggest      !!!!!!!
    Thanx,
    Asit
    Edited by: ASIT_SAP on Jul 15, 2011 6:25 AM
    Edited by: ASIT_SAP on Jul 15, 2011 6:27 AM
    Edited by: ASIT_SAP on Jul 15, 2011 12:37 PM

    Hi Lee, Please see below..
    DECLARE @Machine2 TABLE
    DispatchDate DATE
    INSERT INTO @Machine2 VALUES ('2014/02/01'), ('2014/02/02'), ('2014/02/03')
    DECLARE @DateFrom DATE
    SELECT @DateFrom = DATEADD(D,1,MAX(DispatchDate)) FROM @Machine2
    SELECT @DateFrom AS DateFrom
    Please mark as answer, if this has helped you solve the issue.
    Good Luck :) .. visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.

  • How to create a new row for a VO based on values from another VO?

    Hi, experts.
    in jdev 11.1.2.3,
    How to create a new row for VO1 based on values from another VO2 in the same page?
    and in my use case it's preferable to do this from the UI rather than from business logic layer(EO).
    Also I have read Frank Nimphius' following blog,but in his example the source VO and the destination VO are the same.
    How-to declaratively create new table rows based on existing row content (20-NOV-2008)
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/13-create-with-params-169140.pdf
    I have tried:
    1.VO1(id,amount,remark1) and VO2(id,amount,remark2) are based on different EO,but render in same page,
    2.Drag and drop a Createwithparams button for VO1(id,amount,remark),
    3.add: Create insertinside Createwithparams->Nameddata(amount),
    4.set NDName:amount, NDValue:#{bindings.VO2.children.Amount}, NDtype:oracle.jbo.domain.Number.
    On running,when press button Createwithparams, cannot create a new row for VO1, and get error msg:
    <Utils> <buildFacesMessage> ADF: Adding the following JSF error message: For input string: "Amount"
    java.lang.NumberFormatException: For input string: "Amount"
         at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
    Can anyone give some suggestions?
    Thanks in advance.
    bao
    Edited by: user6715237 on 2013-4-19 下午9:29

    Hi,CM,
    I'm really very appreciated for your quick reply! You know, today is Saturday, it's not a day for everyone at work.
    My principal requirement is as follows:
    1.select/check some rows from VO2, and for each selection create a new row with some attributes from VO2 as default values for VO1's corresponding attributes, and during this process the user may be cancel/uncheck or redo some of the selections.
    --so it's better to implement it in UI rather than in EO.
    2.it's better to implement this function with declarative way as in Frank Nimphius' blog.
    --little Jave/JS coding, the better. I only have experience in ORACLE FORMS, little experience in JAVA/JS.
    In order to get full information for the requirements of my use case, can take a check at:
    How to set default value for a VO query bind variable in a jspx page?
    (the end half of the thread: I have a more realworld requirement similar to the above requirement is:
    Manage bank transactions for clients. and give invoices to clients according to their transaction records. One invoice can contain one or many transactions records. and one transaction records can be split into many invoices.
    Regards
    bao
    Edited by: user6715237 on 2013-4-19 下午11:18
    JAVE->JAVA

  • How to create a new table based out of old data rows

    Hi All,
    How to create a new table based out of old data rows. Also how can we find out the DBF for different users in a database?
    Saqib

    Not very clear what you need. I'll try to interpret...
    How to create a new table based out of old data rowsIf this means how to create a table from an existing one, then you can do :
    SQL> create table <new table> as select * from <old table>;
    if you need a subset of rows you can add a where clause.
    how can we find out the DBF for different users in a database?Here I need some more clarification. What do you mean exactly ?

  • How to create  a procedure to send a mail if the Database is down?

    Hi,
    I have created the below procedure to send a mail if the count is less than 1300. It scheduled daily @ 15 30 hrs. Its fine.
    CREATE OR REPLACE procedure SCOTT.hrsmail
    is
    v_count number;
    begin
    Select count(*) into v_count from emp;
    if v_count < 1300
    then
    UTL_MAIL.send(sender => '[email protected]',
    recipients => '[email protected]',
    cc => '[email protected]',
    bcc => '[email protected]',
    subject => 'Testing the UTL_MAIL Package',
    message => 'If you get this, UTL_MAIL package
    else
    null; --what you want to do here
    end if ;
    end;
    Sometime the Database is down, so the job is not running.
    How to create a procedure to send a mail if the database is down?
    Pls help me. Its highly appreciated.
    Thanks
    Nihar

    nihar wrote:
    How to create a procedure to send a mail if the database is down?And what if the database is up, but the network down? Or the database up and mail server down? Or mail server undergoing maintenance?
    There are loads of "+What if's+" - and in that respect, playing "+What if database is down..+" in this case does not make any sense. You do not use the database to monitor its own up/down status. You do not rely just on SMTP as notification protocol that the database is down.
    The correct approach would be using something like SNMP as the monitoring protocol. A monitoring system that can process SNMP and perform some basic root cause analysis (e.g. network to the database server down, database server status unknown). And this system supporting notification methods like SMTP, SMS and so on.

  • How to create an rule with action to subtract from the event log of Ips manager express console?

    how to create an rule with action to subtract from the event log of Ips manager express console?, some knows of has an guide?.
    Thank you.
    Sent from Cisco Technical Support iPad App

    Hi,
    http://www.cisco.com/en/US/products/sw/secursw/ps2113/products_tech_note09186a0080bc7910.shtml
    HTH
    Luis Silva
    "If you need PDI (Planning, Design, Implement) assistance feel free to reach us"
    http://www.cisco.com/web/partners/tools/pdihd.html

  • How to create a file under web application root from java program

    how to create a file under web application root from java program like an action class?

    like an action class?Huh? What exactly is your requirement?
    Creating a file is usually done with java.io API. Read the java.io tutorials how to play with files.

  • How to create interface where you can view metadata of several databases

    How to create interface where we can view metadata of several databases:
    Oracle Apex should display metadata of this particular DB (later on we can include multiple DB’s)
              a. Report should first display DB name
              b. When clicked on DB name, should display 3 schemas
              c. When clicked on 1 schema, should display tables – when clicked on each table,
              should display various column names and its corresponding metadata.
              (similarly for other schema’s also)
              d. In short, it should be like a drill down report.
    Help required for craeting like above.
    Appreciate your help.

    I did something similar a while back. I had an application reading from multiple schema's for reporting purposes..IN that case atleast we just would build the selects using a function reurning SQL select, so that we could have an application item with the selected schema they wanted to use to build into the select returned...
    For forms, that would be an interesting idea, don't know how you can dynamically change the table owner name, since it is a drop down control in development..
    Thank you,
    Tony Miller
    Webster, TX
    I cried because I did not have an office with a door until I met a man who had no cubicle.
    -Dilbert
    If this question is answered, please mark the thread as closed and assign points where earned..

  • How to create a program that accepts 5 digits from the user between 0 and 9

    how to create a program that accepts 5 digits from the user between 0 and 9 then put them in ascending order using link-list method..

    You can use a scanner to get user input from the command line.
    import java.util.*;
    public class Test {
        private List<Integer> list;
        private Scanner in;
        public static void main (String... args) {
            new Test ();
        public Test () {
            list = new LinkedList<Integer> ();
            in = new Scanner (System.in);
            for (int i = 0; i < 5; i ++) {
                System.out.format ("Please enter a number (%d more): ", (5 - i));
                list.add (in.nextInt ());
            Collections.sort(list, new Comparator<Integer> () {
                public int compare (Integer i1, Integer i2) {
                    return i2 - i1;
            System.out.println (list);
    }

  • How to store and retrieve blob data type in/from oracle database using JSP

    how to store and retrieve blob data type in/from oracle database using JSP and not using servlet
    thanks

    JSP? Why?
    start here: [http://java.sun.com/developer/onlineTraining/JSPIntro/contents.html]

  • How to create internal table dynamically based on a table entry

    hi Experts,
      I have table yprod_cat. It has product categories.
      In my ABAP program I need to create internal table dynamically based on the number of entries in the table.
      For example:
      If the table has 3 entries for product category
      1. Board
      2. Micro
      3. Syst
    Then create three (3) internal tables.
    i_board
    i_micro
    i_syst
    How can we do this? Any sample code will be very usefull
    Thanks & Regards
    Gopal
    Moderator Message: No sample codes can be given. Please search for them or work it!
    Edited by: kishan P on Jan 19, 2011 4:22 PM

    Our APEX version is 4.2We are using below SQL query to display radio groups dynamically..
    SELECT APEX_ITEM.RADIOGROUP (1,deptno,'20',dname) dt
    FROM dept
    ORDER BY 1;
    Created a form using SQL type and given abouve SQL query as source.. But when we run the page, there were no radio groups displayed in the page..
    Below is the output of the query..
    <input type="radio" name="f01" value="10" />ACCOUNTING
    <input type="radio" name="f01" value="20" checked="checked" />RESEARCH
    <input type="radio" name="f01" value="30" />SALES
    <input type="radio" name="f01" value="40" />OPERATIONS
    >
    If Tabular Form:
    Edit Region > Report Attributes > Edit Column > Change the Column type to "Standard Report Column"
    If normal Page Item:
    Edit Page Item > Security > Escape special characters=No.
    Pl read the help on that page item to understand the security risk associated with =NO.
    Cheers,
    Edited by: Prabodh on Dec 3, 2012 5:59 PM

  • How to create a top include for module pool program

    hi all..
      I want to add my global declarations in one top inlcude.. There are so many other includes in my pgm. But how can i create top include explicitly. Also I have one normal report pgm attached with this module pool.

    hi Cynthia ,
       there are two ways of creating a top include at your situation  ,
    1) Insert an include <Prog name >TOP  in your mpool program and cut n paste your declarations there .. check if this works ...
    2)else .. create another m pool program in SE80 , while creating a pop up will ask for with TOP include ... check mark that and then proceed ..
       anything of these two will work ...
    Reward if helpful !!
    Regards,
    Ranjita

  • How to create table top-down approach?

    i know, how to create table in bottom-up approach?
    but i don't know, how to create table in top-down approach?
    please guide me? i am new to abap

    Hi,
    This is called as forward navigation.
    You start first by creating the table.
    You add a field to it.
    You realise that the data element to the field is not there.
    You write the data element name and double click on it.
    It forward navigates to the Create data element screen.
    You want to have a new domain.
    You enter the domain name and double click on it.
    It takes you to Create domain screen.
    You now create domain.
    Go back and assign it to data element.
    Go Back. You now have a field with the required data element.
    Hope that helps!
    Regards,
    Tanveer.
    <b>Please mark helpful answers</b>

  • How to create a flash quiz based on circling the correct answer?

    Hi all,
    I am quite new to actionscripting and need to create a flash based quiz.
    The user will have to circle the correct answer in the quiz.
    I do know of drag and drop function but didn't know how to create circling function.
    Please advise how should I get started.
    Thank you in advance.
    Regards,
    Chewy

    Hi all,
    I am quite new to actionscripting and need to create a flash based quiz.
    The user will have to circle the correct answer in the quiz.
    I do know of drag and drop function but didn't know how to create circling function.
    Please advise how should I get started.
    Thank you in advance.
    Regards,
    Chewy

Maybe you are looking for

  • Can I set up Airport Extreme for wireless printiing over Uverse network?

    I previously had DSL, and used my Airport Extreme as my wireless router. It was in my home office, so my printer was directly plugged into the Base Station. I recently switched to ATT Uverse, which came with its own wireless router. The new router is

  • How to disable print dialog settings being saved, in the registry or otherwise?

    Is it possible to disable the print dialog settings -- such as duplex printing -- from being saved after the Adobe Reader is closed? So each time the application is opened, and one prints a document, it is printed according to default settings? OS: W

  • Substitution rule for AS01

    Hi I want to create a substitution rule to derive jurisdiction code automatically based on responsible cost center for AS01 transaction. How to achieve this. kindly help me. (Create substitution OACS) Thanks

  • Looking for a Tut for Flash Maps

    Has anyone seen a tutorial explaining how to create something similar to the example below? http://www.towncenterplaza.net/StoreDirectory/StoreDirectory.asp?IdS=000F6A-EA0B540&Plugin _Detect=Flash;

  • Reverting back to OSX Mountain Lion

    Can someone please tell me if I can revert back to OSX Mountain Lion from yosemite w/out affecting my backed up file's? some of my files predate mavericks, other's don't. Thank You!