Let's say we've got a database which contains information about football teams playing in a league. There is one column called "no_of_players". Each row for that column tells you the number of players in each football team.
Is there a command that I could use to add up the grand total number of players in the league????
Thanks!
SELECT sum(no_of_players) as TotalPlayers FROM teams WHERE no_of_players != NULL;
Don't forget the !=NULL clause if you have a NULL value there is a good chance that your final value will be NULL since x + NULL = NULL.
Thanks. The funny thing is, it only worked when I removed the where no_of_players!= NULL (otherwise it returned the result "NULL".
I'm very grateful though and I couldn't find that stuff anywhere in the MySQL manual. You're a credit to the forum!
Sorry that was my bad it should have read:
SELECT sum(no_of_players) as TotalPlayers FROM teams WHERE no_of_players IS NOT NULL;
Confusing SQL syntax with programming syntax again. :eek: