Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2004
    Posts
    12

    Red face Unanswered: how to get top 5 entries

    In php, how do get from MS access the top 5 entries for a certain criteria?

    such as, in the employee table, the age field i want to know the top 5 ages like 1st 20: 22 year olds and 2nd 18: 14 year olds and 3rd 15: 19 year olds and so on and so forth.

    what would the codes look like?
    btw thanks bullschmidt for the quick reply!

  2. #2
    Join Date
    Mar 2004
    Location
    Slovenia
    Posts
    56

    Sql

    create query:
    sql view
    SELECT TOP 5 firstname, lastname, salary FROM tblEmployee
    Back to the basics...

  3. #3
    Join Date
    Mar 2004
    Location
    Slovenia
    Posts
    56

    ages

    for ages:

    SELECT TOP 5 ages FROM tblEmployes ORDER BY ages DESC


    sth like that
    Back to the basics...

  4. #4
    Join Date
    Jul 2004
    Posts
    12

    Cool Thanks, that was helpful, but...

    Thanks for that, it came in handy but not exactly what i was looking for. Anybody know how i can select the Most recurring data, instead of the highest value data. for the field age in the table employee.

    Thanks!

  5. #5
    Join Date
    Feb 2002
    Posts
    12
    Jemmo,

    Try using the "count" function. Here is my small example. My table is called Sheet1:

    Name Age
    Diane 35
    John 39
    Tami 35
    Colson 3
    Eli 1
    Avery 3
    Janet 40
    John 40
    Bill 40

    SELECT TOP 3 Sheet1.Age, Count(Sheet1.Name) AS CountOfName
    FROM Sheet1
    GROUP BY Sheet1.Age
    ORDER BY Count(Sheet1.Name) DESC;

    It returns:

    Age CountOfName
    40 3
    35 2
    3 2

    Hope that is what you are looking for.
    Diane

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •