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

  • Home
  • SEARCH
  • 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 7491627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:05:29+00:00 2026-05-29T16:05:29+00:00

My website allows users to record bids. Each bid is saved individually and associated

  • 0

My website allows users to record bids. Each bid is saved individually and associated to a user Id. A user can have many bids which are used to add up to one overall bid which is displayed upon the site.

What I am trying to do in sql is return the position a users overall bid is from a result set.

The sql I am using is below but problems arise when I use the group by command – the ordering seems to revert back to the default db order rather than by the sum of a users bid amounts:

SET @rowcount = 0;
SELECT rowCount, userId FROM (
    SELECT userId, @rowcount := @rowcount + 1 as rowCount, sum(amount) as amount FROM bids group by userId order by amount desc
 ) t when product = xxxxx

appreciate if anyone knows if this is possible?

  • 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-29T16:05:29+00:00Added an answer on May 29, 2026 at 4:05 pm

    You need to move rowcount incrementation out of subquery. And put your WHERE condition inside, otherwise your subquery will sum bids on all products for a given user.

    SET @rowcount = 0;
    SELECT @rowCount:=@rowcount+1 as rowcount, userId, amount FROM 
     (
        SELECT userId, sum(amount) as amount 
        FROM bids 
        WHERE product = xxxxx 
        GROUP BY userId 
        ORDER BY amount DESC
     ) t 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website which allows users to submit photos of wildlife. Once uploaded,
I have a requirement to setup a website that allows users, user blogs, a
I have an entries controller that allows users to add contact information the website.
I have a website that allows a user to upload a spreadsheet of items
I have an asp.net website that allows the user to download largish files -
I have a website which allows secure (ssl) file uploads and download. The site
I have a website that allows users from around the world to submit profiles.
I currently have a website (ASP.NET 3.5, IIS 7.0) that allows users to upload
I’m developing a website which allows users to join with GFC (Google Friend Connect).
My website allows users to upload profile images, which are then represented in several

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.