Jump to content

Sql Sum Problem


traxion

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 comment
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 comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...