I'm sort of a noob when it comes to MySQL, I was wondering how to count all the numbers in a column. I have tried numerous ways with the COUNT(*) and COUNT function queries, but have had no success. For example, I have the column titled 'Money' [url]http://gyazo.com/e22ce1121ae15fe403d7b2d8e41ccb56[/url]
I want to count all the numbers in that column, how would I achieve this? (i.e the total of all the money in the database)
SELECT SUM( column )
[QUOTE=zzaacckk;39309972]SELECT SUM( column )[/QUOTE]
:D!
You're awesome.
Now is there anyway I can exclude certain values from that, or am I just going to have to make separate queries to query for those and subtract?
SELECT SUM( column ) FROM table WHERE `TimePlayed` > 5000;
[QUOTE=zzaacckk;39310745]SELECT SUM( column ) FROM table WHERE `TimePlayed` > 5000;[/QUOTE]Thank you. Now I've run into the problem, when I call getData() (mysqloo), it returns the table as so.
[url]http://gyazo.com/3e91047ebdd3ce8956ab2e5170e56b56[/url]
I can't call print(table[1].sum(money)) since it says "Attempted to index sum, a nil value".
Is there any workaround?
[QUOTE=Lerpaderp;39310889]Thank you. Now I've run into the problem, when I call getData() (mysqloo), it returns the table as so.
[url]http://gyazo.com/3e91047ebdd3ce8956ab2e5170e56b56[/url]
I can't call print(table[1].sum(money)) since it says "Attempted to index sum, a nil value".
Is there any workaround?[/QUOTE]
print( table[1]["sum(money)"] );
[QUOTE=zzaacckk;39310912]print( table[1]["sum(money)"] );[/QUOTE]
I love you.
Thank you soooooooooooooooooooooooo much.
You could also do SELECT SUM( money ) AS 'money' and then do table[ 1 ].money
Sorry, you need to Log In to post a reply to this thread.