PDA

View Full Version : Count ? math via query - help


miz
01-25-2005, 02:41 PM
i tried to count all users posts and calculte them as team posts

like that

COUNT(user.posts) AS totalteamposts

but its count rows and not posts
any idea how i can count all posts via query ?

Carnage
01-25-2005, 02:45 PM
try this:


SELECT sum(user.posts) AS `totalteamposts`


edit: my error should have used ` not ' (i've done this ever since i had the problem of selecting the coloum `mod` from a table... apparently MOD is an sql function, took me hours to figure out what was wrong there...)

filburt1
01-25-2005, 02:51 PM
Don't enclose the table name in quotes.

In ANSI SQL, you should absolutely never use quotes (that I know of) except for literal strings. Column names, numeric values, column aliases, etc. should always be left unquoted.

miz
01-25-2005, 03:05 PM
thanx for help
i used
sum(user.posts) AS teamposts,

worked like charm