Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6538671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:45:48+00:00 2026-05-25T10:45:48+00:00

Using the table code below I was asked to draw out a list sorted

  • 0

Using the table code below I was asked to draw out a list sorted by the rankings of each item. Each column rank# is how each user would rank that item. So for an item A if it was ranked 1 by one user and 16 by another its overall ranking should be 8. Is there a possible SQL query for this or process it in PHP?

CREATE TABLE `rankings` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `userId` int(11) NOT NULL,
  `rank1` int(11) NOT NULL,
  `rank2` int(11) NOT NULL,
  `rank3` int(11) NOT NULL,
  `rank4` int(11) NOT NULL,
  `rank5` int(11) NOT NULL,
  `rank6` int(11) NOT NULL,
  `rank7` int(11) NOT NULL,
  `rank8` int(11) NOT NULL,
  `rank9` int(11) NOT NULL,
  `rank10` int(11) NOT NULL,
  `rank11` int(11) NOT NULL,
  `rank12` int(11) NOT NULL,
  `rank13` int(11) NOT NULL,
  `rank14` int(11) NOT NULL,
  `rank15` int(11) NOT NULL,
   `rank16` int(11) NOT NULL,
  `submissionTimestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

Here is the table that each rank# column is referenced to:

CREATE TABLE `rankableItems` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`itemName` varchar(30) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=latin1;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:45:48+00:00Added an answer on May 25, 2026 at 10:45 am

    I think you take it the wrong way. Here what you could do that will be much more simple to work with and to understand :

    create table `ranking` (
        `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
        `user_id` int(11) unsigned NOT NULL,
        `item_id` int(11) unsigned NOT NULL,
        `item_rank` int(11) unsigned NOT NULL
    )
    

    And the associated query to get the average ranking :

    SELECT AVG(item_rank) AS AVG_RANK 
    FROM ranking 
    WHERE item_id = 'xxx'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the code below I am using a recursive CTE(Common Table Expression) in SQL
I am using the code below to do pagination on a table (please do
Using jQuery 1.4.4. When a user mouses over the table element below, I want
How can i set the width of a table column using jquery. The code
Should I still be using tables anyway? The table code I'd be replacing is:
Existing code is using an asp:repeater to build an HTML table. (emphasis on the
I'm using this code to reset the identity on a table: DBCC CHECKIDENT('TableName', RESEED,
I can drop a table if it exists using the following code but do
Note The question below was asked in 2008 about some code from 2003. As
I am using table view for editing an object . I am using below

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.