Topic: sorting by collective value of inventory
When viewing all users for a certain geographic area it'd be cool if you could sort by parameters like "total value of inventory" or "total cards in inventory".
Doing something like this wouldn't be very efficient:
SELECT username, totalValue
FROM (
SELECT username, SUM(value) AS totalValue
FROM users
JOIN cards ON cards.user_id = users.user_id
WHERE location = 'Texas, USA'
GROUP BY username
)
ORDER BY totalValue
But maybe there could be a total value column and a total cards column in the users table. The total cards column would be updated every time a card was added or removed and the total value column could be updated every time someone clicked the "Show Value" button on a particular inventory.