Jump to content

Sql Sum Problem


Recommended Posts

i've got a mysql table images with a field id, game_id, datum (time in dutch), aantal (amount in dutch) and some more field, but those not mater right nowinside the table i will save the time and game_id of the images and how much there are uploaded, the images names are not saved inside the database. i will pick those out of the maps on the server.now i want to select the last 10 images for example. The idee was that i just needed to calculate the SUM of aantal until i've hit the 10.this can be in 1 record or in 7 records.

SELECT SUM(aantal) as b FROM `images` WHERE game_id = 10020 AND b > 10

now i want to create a query like that but im not sure how?does anybody here has an idee?running a query with LIMIT 1 record and then with LIMIT 2 (+1) until the limit is reached is not really a solution.. thats not nice

Link to post
Share on other sites
  • 2 weeks later...
select id, game_id, datum, aantalfrom imagesorder by datum desclimit 10

I don't know whether I've understood your request, is this the solution?regardsstefano De Boni

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...